:root{
  --bg:#fefae0;
  --panel:#ffffff;
  --panel-2:#fffaf1;
  --text:#211f1c;
  --muted:#696057;
  --line:#ded3c1;
  --accent:#6b225c;
  --accent-2:#8d3f7e;
  --good:#237a45;
  --bad:#b13a2d;
  --shadow:0 18px 45px rgba(80, 47, 21, .12);
  --radius:18px;
}

*{ box-sizing:border-box; }

body{
  margin:0;
  min-height:100vh;
  font-family:Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at top left, rgba(107,34,92,.10), transparent 34rem),
    linear-gradient(180deg, #fffaf1, var(--bg));
}

body.dragging::after{
  content:"Drop PDF files anywhere";
  position:fixed;
  inset:18px;
  z-index:999;
  display:grid;
  place-items:center;
  font-size:clamp(1.5rem, 3vw, 3rem);
  font-weight:800;
  color:var(--accent);
  border:3px dashed var(--accent);
  border-radius:28px;
  background:#fefae0;
  box-shadow:0 0 0 999px rgba(33,31,28,.15);
  pointer-events:none;
}

.app{
  width:min(1280px, calc(100vw - 28px));
  margin:0 auto;
  padding:22px 0 42px;
}

header{
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
  margin-bottom:16px;
}

.title h1{
  margin:0;
  font-size:clamp(1.5rem, 2.6vw, 2.35rem);
  letter-spacing:-.04em;
}

.title p{
  margin:.35rem 0 0;
  color:var(--muted);
  max-width:800px;
  line-height:1.45;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 11px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.66);
  color:var(--muted);
  font-size:.9rem;
  white-space:nowrap;
}

.layout{
  display:grid;
  grid-template-columns:minmax(280px, 365px) minmax(0, 1fr);
  gap:18px;
  align-items:start;
}

.card{
  background:rgba(255,255,255,.82);
  border:1px solid rgba(222,211,193,.9);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  backdrop-filter:blur(8px);
}

.side{
  position:sticky;
  top:16px;
}

.drop{
  min-height:230px;
  display:grid;
  place-items:center;
  text-align:center;
  padding:26px;
  border:2px dashed rgba(107,34,92,.35);
  border-radius:calc(var(--radius) - 2px);
  margin:14px;
  background:linear-gradient(180deg, #fff, var(--panel-2));
  transition:.18s ease;
}

.drop:hover,
.drop.hot{
  border-color:var(--accent);
  transform:translateY(-1px);
  box-shadow:0 12px 30px rgba(107,34,92,.10);
}

.drop svg{
  width:54px;
  height:54px;
  color:var(--accent);
  margin-bottom:14px;
}

.drop h2{
  margin:.15rem 0 .35rem;
  font-size:1.22rem;
  letter-spacing:-.02em;
}

.drop p{
  margin:0;
  color:var(--muted);
  line-height:1.4;
  font-size:.95rem;
}

input[type="file"]{ display:none; }

button,
.button{
  appearance:none;
  border:1px solid rgba(107,34,92,.28);
  background:rgba(255,255,255,.75);
  color:var(--text);
  border-radius:12px;
  padding:10px 13px;
  font:inherit;
  cursor:pointer;
  transition:.16s ease;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:40px;
  text-decoration:none;
}

button:hover,
.button:hover{
  border-color:var(--accent);
  color:var(--accent);
  transform:translateY(-1px);
}

button.primary{
  border-color:var(--accent);
  background:linear-gradient(180deg, var(--accent-2), var(--accent));
  color:white;
  font-weight:750;
  box-shadow:0 12px 24px rgba(107,34,92,.18);
}

button.primary:hover{ color:white; filter:brightness(1.05); }
button:disabled{ opacity:.45; cursor:not-allowed; transform:none; }

.controls{
  padding:0 14px 14px;
  display:grid;
  gap:12px;
}

.row{ display:flex; gap:8px; flex-wrap:wrap; }
.row > *{ flex:1 1 auto; }

.selectedHint{
  margin:-2px 0 0;
  color:var(--muted);
  font-size:.82rem;
  line-height:1.35;
}

label.field{
  display:grid;
  gap:7px;
  color:var(--muted);
  font-size:.88rem;
}

select,
input[type="text"]{
  width:100%;
  border:1px solid var(--line);
  background:white;
  border-radius:12px;
  padding:10px 12px;
  color:var(--text);
  font:inherit;
}

.tickLine{
  display:flex;
  gap:9px;
  align-items:flex-start;
  color:var(--text);
  font-size:.88rem;
  line-height:1.35;
  cursor:pointer;
  user-select:none;
}

.tickLine input{
  width:17px;
  height:17px;
  margin-top:1px;
  accent-color:var(--accent);
  flex:0 0 auto;
}

.tickLine small{
  display:block;
  color:var(--muted);
  margin-top:2px;
}

.stats{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:8px;
  padding:14px;
  border-top:1px solid var(--line);
  background:rgba(255,250,241,.65);
}

.stat{
  padding:10px;
  border:1px solid var(--line);
  border-radius:14px;
  background:white;
}

.stat b{
  display:block;
  font-size:1.28rem;
  line-height:1.1;
  color:var(--accent);
}

.stat span{
  display:block;
  margin-top:3px;
  color:var(--muted);
  font-size:.78rem;
}

.log{
  max-height:170px;
  overflow:auto;
  padding:14px;
  border-top:1px solid var(--line);
  color:var(--muted);
  font-size:.88rem;
  line-height:1.45;
  background:#fffdf8;
}

.log div + div{ margin-top:6px; }
.log .ok{ color:var(--good); }
.log .err{ color:var(--bad); }

.previewHeader{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
  padding:14px 16px;
  border-bottom:1px solid var(--line);
  background:rgba(255,250,241,.65);
}

.previewHeader h2{
  margin:0;
  font-size:1.02rem;
  letter-spacing:-.02em;
}

.previewHeader small{
  color:var(--muted);
}

.fileList{
  display:grid;
  gap:14px;
  padding:14px;
  min-height:350px;
}

.empty{
  min-height:340px;
  border:1px dashed var(--line);
  border-radius:16px;
  display:grid;
  place-items:center;
  text-align:center;
  color:var(--muted);
  padding:22px;
  background:rgba(255,255,255,.55);
}

.fileBlock{
  border:1px solid var(--line);
  border-radius:16px;
  overflow:hidden;
  background:white;
}

.fileTop{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  background:#fffaf1;
  border-bottom:1px solid var(--line);
}

.fileName{
  min-width:0;
  display:grid;
  gap:2px;
}

.fileName strong{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:.95rem;
}

.fileName span{
  color:var(--muted);
  font-size:.82rem;
}

.remove{
  max-width:max-content;
  min-height:32px;
  padding:7px 9px;
  border-radius:10px;
  color:var(--bad);
}

.pages{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(132px, 1fr));
  gap:12px;
  padding:12px;
}

.pageCard{
  border:1px solid var(--line);
  border-radius:14px;
  background:#fffdf8;
  overflow:hidden;
  min-height:248px;
  display:grid;
  grid-template-rows:auto 1fr auto;
}

.pageCard.checked{
  border-color:rgba(107,34,92,.65);
  box-shadow:0 0 0 3px rgba(107,34,92,.10);
}

.pageActions{
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:space-between;
  padding:8px 9px;
  border-bottom:1px solid var(--line);
  background:white;
}

.checkLine{
  display:flex;
  align-items:center;
  gap:7px;
  color:var(--text);
  font-size:.78rem;
  cursor:pointer;
  user-select:none;
  min-width:0;
}

.checkLine input{
  width:16px;
  height:16px;
  accent-color:var(--accent);
  flex:0 0 auto;
}

.rotateBtn{
  width:34px;
  height:34px;
  min-height:34px;
  padding:0;
  border-radius:999px;
  font-size:1.18rem;
  line-height:1;
  flex:0 0 auto;
}

.rotateBtn.active{
  border-color:var(--accent);
  color:var(--accent);
  box-shadow:0 0 0 3px rgba(107,34,92,.10);
}

.thumbWrap{
  display:grid;
  place-items:center;
  min-height:174px;
  padding:10px;
  background:
    linear-gradient(45deg, rgba(222,211,193,.35) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(222,211,193,.35) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(222,211,193,.35) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(222,211,193,.35) 75%);
  background-size:18px 18px;
  background-position:0 0, 0 9px, 9px -9px, -9px 0;
}

.pageCard canvas,
.pageCard img{
  max-width:100%;
  max-height:160px;
  background:white;
  box-shadow:0 6px 18px rgba(0,0,0,.14);
}

.pageMeta{
  display:flex;
  justify-content:space-between;
  gap:6px;
  padding:8px 9px;
  color:var(--muted);
  font-size:.77rem;
  border-top:1px solid var(--line);
  background:white;
}

.progressBox{
  padding:0 14px 14px;
  display:none;
}

.progressBox.show{ display:block; }

.bar{
  height:10px;
  border-radius:999px;
  overflow:hidden;
  background:#eee1d1;
  border:1px solid var(--line);
}

.bar span{
  display:block;
  height:100%;
  width:0%;
  border-radius:inherit;
  background:linear-gradient(90deg, var(--accent-2), var(--accent));
  transition:width .18s ease;
}

.progressText{
  margin-top:7px;
  color:var(--muted);
  font-size:.86rem;
}

@media (max-width: 850px){
  .layout{ grid-template-columns:1fr; }
  .side{ position:static; }
  header{ align-items:flex-start; flex-direction:column; }
}

.previewQueued{
  color:var(--muted);
  font-size:.8rem;
}

.previewError{
  color:var(--bad);
  font-size:.8rem;
}

.empty.compact{
  min-height:160px;
}

.empty.errorText{
  color:var(--bad);
}
