:root{
  --page:#f4f6f8;
  --panel:#ffffff;
  --soft:#f8fafc;
  --text:#1f2933;
  --muted:#667085;
  --line:#d9e2ec;
  --brand:#1766a6;
  --brand-dark:#0d4777;
  --brand-soft:#e8f3fb;
  --good:#137333;
  --bad:#bf1f1f;
  --shadow:0 14px 36px rgba(15, 23, 42, .08);
  --radius:14px;
}

*{ box-sizing:border-box; }

body{
  margin:0;
  min-height:100vh;
  font-family:Arial, Helvetica, sans-serif;
  color:var(--text);
  background:linear-gradient(180deg, #ffffff 0, var(--page) 280px, var(--page) 100%);
}

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(--brand-dark);
  border:3px dashed var(--brand);
  border-radius:24px;
  background:rgba(255,255,255,.9);
  box-shadow:0 0 0 999px rgba(15,23,42,.16);
  pointer-events:none;
}

.siteShell{
  width:min(1240px, calc(100vw - 28px));
  margin:0 auto;
  padding:20px 0 42px;
}

.topNav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:12px 0 18px;
  border-bottom:1px solid var(--line);
}

.brand{
  color:var(--brand-dark);
  font-weight:800;
  font-size:1.15rem;
  text-decoration:none;
  letter-spacing:-.02em;
}

.navLinks{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.navLinks a{
  color:var(--text);
  text-decoration:none;
  padding:8px 11px;
  border-radius:999px;
  font-size:.92rem;
}

.navLinks a:hover{
  background:var(--brand-soft);
  color:var(--brand-dark);
}

.hero{
  display:flex;
  justify-content:space-between;
  align-items:end;
  gap:20px;
  padding:28px 0 18px;
}

.eyebrow{
  margin:0 0 6px;
  color:var(--brand);
  font-weight:700;
  font-size:.92rem;
}

.hero h1{
  margin:0;
  font-size:clamp(2rem, 4vw, 3.2rem);
  letter-spacing:-.05em;
  line-height:.95;
}

.hero p:last-child{
  margin:12px 0 0;
  color:var(--muted);
  max-width:760px;
  line-height:1.48;
}


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

.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}

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

.drop{
  min-height:220px;
  display:grid;
  place-items:center;
  text-align:center;
  padding:26px;
  border:2px dashed #9fc6e6;
  border-radius:12px;
  margin:14px;
  background:linear-gradient(180deg, #ffffff, var(--soft));
  transition:.18s ease;
}

.drop:hover,
.drop.hot{
  border-color:var(--brand);
  transform:translateY(-1px);
  box-shadow:0 12px 26px rgba(23,102,166,.12);
}

.dropIcon{
  display:inline-grid;
  place-items:center;
  width:64px;
  height:64px;
  border-radius:16px;
  background:var(--brand-soft);
  color:var(--brand-dark);
  margin-bottom:14px;
}

.drop svg{
  width:40px;
  height:40px;
}

.drop h2{
  margin:.15rem 0 .35rem;
  font-size:1.18rem;
}

.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 #c6d4e1;
  background:#ffffff;
  color:var(--text);
  border-radius:10px;
  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(--brand);
  color:var(--brand-dark);
  transform:translateY(-1px);
}

button.primary{
  border-color:var(--brand-dark);
  background:linear-gradient(180deg, var(--brand), var(--brand-dark));
  color:white;
  font-weight:700;
  box-shadow:0 12px 22px rgba(23,102,166,.2);
}

button.primary:hover{ color:white; filter:brightness(1.04); }
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; }

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

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

select:focus,
input[type="text"]:focus{
  outline:3px solid rgba(23,102,166,.14);
  border-color:var(--brand);
}

.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(--brand);
  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:var(--soft);
}

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

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

.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:#ffffff;
}

.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:var(--soft);
}

.previewHeader h2{
  margin:0;
  font-size:1.02rem;
}

.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:14px;
  display:grid;
  place-items:center;
  text-align:center;
  color:var(--muted);
  padding:22px;
  background:var(--soft);
}

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

.fileTop{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  background:var(--soft);
  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:9px;
  color:var(--bad);
}

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

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

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

.pageRemoveBtn{
  width:34px;
  height:34px;
  min-height:34px;
  padding:0;
  border-radius:999px;
  font-size:1.55rem;
  line-height:1;
  font-weight:700;
  color:var(--bad);
  background:#fff;
}

.pageRemoveBtn:hover{
  border-color:var(--bad);
  color:#8f1111;
  background:#fff5f5;
}

.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(--brand);
  color:var(--brand-dark);
  box-shadow:0 0 0 3px rgba(23,102,166,.12);
}

.thumbWrap{
  display:grid;
  place-items:center;
  min-height:174px;
  padding:10px;
  background:
    linear-gradient(45deg, rgba(217,226,236,.45) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(217,226,236,.45) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(217,226,236,.45) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(217,226,236,.45) 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 16px rgba(15,23,42,.15);
}

.pageMeta{
  display:grid;
  gap:3px;
  padding:8px 9px;
  color:var(--muted);
  font-size:.77rem;
  border-top:1px solid var(--line);
  background:white;
}

.pageMeta span:first-child{
  color:var(--text);
  font-weight:700;
}

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

.progressBox.show{ display:block; }

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

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

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

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

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

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

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

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

/* Server-rendered preview images */
.thumbWrap img{
  display:block;
  max-width:130px;
  max-height:168px;
  width:auto;
  height:auto;
  background:#fff;
  box-shadow:0 2px 8px rgba(15,23,42,.12);
}

/* CLC Book Prep server connection state */
.serverPill{display:inline-flex;align-items:center;gap:8px;padding:8px 11px;border:1px solid var(--line);border-radius:999px;background:#fff;font-size:12px;white-space:nowrap}
.serverPill span{width:9px;height:9px;border-radius:50%;background:#9aa0a6}
.serverPill.ready span{background:#2d8a54}.serverPill.error span{background:#b83a3a}.serverPill.checking span{animation:pulse 1s infinite alternate}
.connectionBox{margin-top:14px;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:#fff;display:flex;gap:10px;align-items:center;justify-content:space-between;font-size:13px}
.connectionBox.ready{border-color:#bcdcc9;background:#f5fbf7}.connectionBox.error{border-color:#e8baba;background:#fff7f7}.connectionBox.checking{background:#fafafa}
.connectionBox button{white-space:nowrap}.connectionBox.ready button{display:none}
.previewRetry{border:0;background:transparent;text-decoration:underline;cursor:pointer;font-size:12px;padding:8px;color:inherit}
@keyframes pulse{from{opacity:.35}to{opacity:1}}
@media (max-width:700px){.serverPill b{display:none}.connectionBox{align-items:flex-start;flex-direction:column}}
