/* PDF Arranger — standalone tool page. Palette mirrors the landing page. */
:root {
  --paper:   #FAFAF7;
  --paper-2: #FFFFFF;
  --panel:   #F3F5F1;
  --ink:     #14181F;
  --ink-soft:#2A2F38;
  --green:   #195583;
  --green-d: #12425F;
  --green-h: #21618F;
  --orange:  #FD7118;
  --orange-d:#E8620A;
  --tint:    #E8F1F8;
  --line:    #E4E2D9;
  --line-2:  #D5D3C8;
  --mut:     #565C63;
  --danger:  #C0392B;
  --serif:   'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans:    'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --wrap:    1200px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--paper); color: var(--ink); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
.serif { font-family: var(--serif); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 32px; }

/* Nav */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(250,250,247,0.92); backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand-logo { height: 40px; width: auto; display: block; }
.nav-right { display: flex; align-items: center; gap: 22px; }
.nav-right a.back { font-size: 15px; color: var(--ink-soft); }
.nav-right a.back:hover { color: var(--green); }
.nav-login { font-weight: 500; color: var(--ink) !important; border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 16px; transition: border-color .15s, background .15s, color .15s; }
.nav-login:hover { border-color: var(--green); background: var(--tint); color: var(--green) !important; }

/* Head */
.head { padding: 40px 0 8px; }
.head .eyebrow { font-size: 14px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--green); }
.head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 4vw, 44px); line-height: 1.08; margin-top: 12px; letter-spacing: -.01em; }
.head p.lead { color: var(--mut); font-size: 17px; margin-top: 14px; max-width: 62ch; }

/* Empty state / drop zone */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  margin: 34px 0 60px; padding: 64px 28px; }
.dropzone { width: 100%; max-width: 720px; border: 2px dashed var(--line-2); border-radius: 18px; background: var(--paper-2);
  padding: 56px 32px; transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--green); background: var(--tint); }
.dz-ic { width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 14px; background: var(--tint); color: var(--green);
  display: flex; align-items: center; justify-content: center; }
.dz-ic svg { width: 30px; height: 30px; }
.dropzone h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; }
.dropzone p { color: var(--mut); margin-top: 8px; font-size: 15px; }
.dz-hint { margin-top: 20px; font-size: 13px; color: var(--mut); }
.dz-hint b { color: var(--ink-soft); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; padding: 11px 22px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s, color .15s; }
.btn svg { width: 16px; height: 16px; }
.btn-solid { background: var(--orange); color: #fff; }
.btn-solid:hover { background: var(--orange-d); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-h); }
.btn-primary:disabled { background: var(--line-2); color: #fff; cursor: not-allowed; }
.btn-out { border-color: var(--line-2); color: var(--ink); background: var(--paper-2); }
.btn-out:hover { border-color: var(--ink); }
.btn-ghost { color: var(--mut); background: transparent; }
.btn-ghost:hover { color: var(--danger); }

/* Toolbar (sticky) */
.toolbar { display: none; position: sticky; top: 60px; z-index: 40; align-items: center; gap: 14px; flex-wrap: wrap;
  background: rgba(250,250,247,0.94); backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line); padding: 12px 0; margin-bottom: 24px; }
.toolbar .count { font-size: 15px; font-weight: 600; color: var(--ink); }
.toolbar .spacer { flex: 1; }
.toolbar .status { font-size: 14px; min-height: 20px; }
.toolbar .status.ok { color: var(--green-d); }
.toolbar .status.err { color: var(--danger); }

/* Workspace + grid */
.workspace { display: none; padding-bottom: 80px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px; }

.card { position: relative; background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  cursor: grab; transition: box-shadow .15s, border-color .15s, transform .12s; user-select: none; }
.card:hover { border-color: var(--line-2); box-shadow: 0 6px 18px rgba(20,24,31,.08); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .45; }
.card.drop-before { box-shadow: -3px 0 0 0 var(--green); }
.card.drop-after  { box-shadow:  3px 0 0 0 var(--green); }

.thumb { position: relative; display: flex; align-items: center; justify-content: center; min-height: 150px;
  background: var(--panel); border-radius: 6px; overflow: hidden; }
.thumb canvas { display: block; max-width: 100%; height: auto; box-shadow: 0 1px 4px rgba(20,24,31,.12); }
.thumb-loading { width: 26px; height: 26px; border: 3px solid var(--line-2); border-top-color: var(--green);
  border-radius: 50%; animation: spin .8s linear infinite; }
.thumb-err { font-size: 12px; color: var(--danger); padding: 20px; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

.card-num { position: absolute; left: 16px; top: 16px; min-width: 24px; height: 24px; padding: 0 7px;
  background: rgba(20,24,31,.78); color: #fff; font-size: 13px; font-weight: 600; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.card-tools { position: absolute; right: 14px; top: 14px; display: flex; gap: 6px; opacity: 0; transition: opacity .12s; }
.card:hover .card-tools, .card:focus-within .card-tools { opacity: 1; }
.ct { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: rgba(255,255,255,.95); border: 1px solid var(--line-2); border-radius: 7px; color: var(--ink-soft);
  transition: background .12s, color .12s, border-color .12s; }
.ct svg { width: 15px; height: 15px; }
.ct:hover { background: var(--tint); color: var(--green); border-color: var(--green); }
.ct.del:hover { background: #FBEAE8; color: var(--danger); border-color: var(--danger); }

/* Overlay */
.overlay { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(20,24,31,.55);
  align-items: center; justify-content: center; }
.overlay .box { background: var(--paper-2); border-radius: 14px; padding: 30px 40px; display: flex; align-items: center; gap: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.overlay .sp { width: 24px; height: 24px; border: 3px solid var(--line-2); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
.overlay .msg { font-size: 15px; font-weight: 500; }

/* Footer note */
.foot { border-top: 1px solid var(--line); padding: 26px 0; color: var(--mut); font-size: 13px; }
.foot .lock { display: inline-flex; align-items: center; gap: 7px; }
.foot .lock svg { width: 15px; height: 15px; color: #47993E; }

@media (max-width: 640px) {
  .wrap { padding: 0 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
  .toolbar { top: 60px; }
}
