/* =========================================================
   PDFMaster — modern redesign (selectors preserved)
   Gradient indigo -> violet -> pink, glass surfaces, soft shadows.
   ========================================================= */
:root {
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-3: #ec4899;
  --primary-dark: #4f46e5;
  --primary-soft: #eef2ff;
  --accent: #8b5cf6;
  --surface: #ffffff;
  --bg: #f5f6fd;
  --bg-grad-1: #ede9fe;
  --bg-grad-2: #fce7f3;
  --card: #ffffff;
  --text: #1e1b2e;
  --muted: #6b7280;
  --border: #e8e6f3;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.04), 0 10px 30px rgba(99, 102, 241, 0.08);
  --shadow-lg: 0 18px 50px rgba(139, 92, 246, 0.18);
  --ring: 0 0 0 3px rgba(139, 92, 246, 0.28);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #ec4899);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 700px at 100% -10%, var(--bg-grad-2), transparent 60%),
    radial-gradient(1100px 600px at -10% 110%, var(--bg-grad-1), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(232, 230, 243, 0.8);
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 27px;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--grad);
  border-radius: 15px;
  box-shadow: 0 8px 22px rgba(139, 92, 246, 0.4);
}
.topbar h1, .topbar .brandname {
  font-size: 21px; margin: 0;
  font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 0; font-size: 12px; color: var(--muted); }
.langwrap { font-size: 13px; color: var(--muted); display: flex; flex-direction: row; align-items: center; gap: 8px; }
.langwrap > span[data-i18n="lang"] { display: none; }
.langwrap select {
  appearance: none; -webkit-appearance: none;
  padding: 8px 32px 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--primary-soft) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b5cf6' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 12px center;
  font-size: 13px; font-weight: 600; color: var(--primary-dark); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.langwrap select:hover { border-color: #c4b5fd; }
.langwrap select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

/* ---------------- Inputs ---------------- */
select, input[type=text], input[type=number] {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input[type=text]:focus, input[type=number]:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--ring);
}

/* ---------------- Tabs ---------------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(232, 230, 243, 0.8);
  position: sticky; top: 78px; z-index: 20;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none; background: transparent; color: var(--muted); font-size: 14px;
  padding: 10px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font-weight: 600; transition: background .15s, color .15s, transform .1s;
  font-family: var(--font, inherit); line-height: 1.55;
}
.tab:hover { background: var(--primary-soft); color: var(--primary-dark); }
.tab:active { transform: translateY(1px); }
.tab.active {
  background: var(--grad);
  color: #fff; font-weight: 700;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.42);
}

/* ---------------- Layout ---------------- */
.container { max-width: 820px; margin: 0 auto; padding: 22px 18px 40px; }
.panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  animation: fadeUp .25s ease;
}
.panel.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel h2 { margin: 0 0 6px; font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.desc { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.row.between { justify-content: space-between; }

/* ---------------- Buttons ---------------- */
.btn {
  border: none; background: var(--grad);
  color: #fff; padding: 12px 20px;
  border-radius: 14px; font-size: 14px; cursor: pointer; font-weight: 700;
  transition: transform .1s, box-shadow .15s, filter .15s;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.34);
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 10px 26px rgba(139, 92, 246, 0.46); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: var(--primary-soft); color: var(--primary-dark);
  border: 1px solid #c4b5fd; display: inline-flex; align-items: center;
  box-shadow: none;
}
.btn.ghost:hover { background: #e0e7ff; filter: none; }
.btn.primary { width: 100%; margin-top: 10px; padding: 14px; font-size: 15px; }
.mini {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 13px; border-radius: 10px; cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s;
}
.mini:hover { background: #f8fafc; }
.mini.danger { color: var(--danger); border-color: #fecaca; }
.mini.danger:hover { background: var(--danger-soft); }

.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.autocrop { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }

/* ---------------- Signature tool ---------------- */
.sigtools { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin: 8px 0; }
.sigtool { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.sigtool select, .sigtool input[type=range] { font-size: 13px; }
.sigtool select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.signpad {
  display: block; width: 100%; max-width: 482px; height: auto; aspect-ratio: 1.618 / 1;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(135deg, #eef2ff 0 10px, #fff 10px 20px) border-box;
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); touch-action: none; cursor: crosshair;
}
/* Mode mobile: signpad mengikuti lebar layar (full-width) dengan rasio 4:3 */
@media (max-width: 760px) {
  .signpad { max-width: none; width: 100%; }
}
.signpreview {
  display: flex; flex-direction: row; gap: 14px;
  max-height: 620px; overflow-x: auto; overflow-y: hidden; margin: 10px 0 14px; padding: 10px;
  border: 1px solid var(--border); border-radius: 16px;
  background: linear-gradient(180deg, #faf8ff, #eef2ff);
  scroll-snap-type: x mandatory;
}
.signpreview .ppage { scroll-snap-align: center; }
.signpreview .ppage { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.signpreview .ppage .pscroll { position: relative; top: 0; left: 0; width: 100%; max-height: 560px; overflow: auto; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.signpreview .ppage .pcanvas { position: relative; top: 0; left: 0; width: 100%; }
.signpreview .ppage .pcanvas img { display: block; width: 100%; height: 100%; object-fit: fill; }
.signpreview .ppage .pcheck { position: absolute; top: 6px; left: 6px; background: rgba(255,255,255,0.94); border-radius: 8px; padding: 4px 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 10; }
.signpreview .ppage .pcheck input { width: 16px; height: 16px; accent-color: var(--primary); }
.signpreview .ppage .pzoomctl { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; align-items: center; z-index: 10; background: rgba(255,255,255,0.94); border: 1px solid var(--border); border-radius: 10px; padding: 3px; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.signpreview .ppage .pzoomctl button { width: 28px; height: 28px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1; }
.signpreview .ppage .pzoomctl button:hover { background: var(--primary-soft); }
.signpreview .ppage .pzoomctl .pzoomval { min-width: 40px; text-align: center; font-size: 12px; background: rgba(255,255,255,0.94); border-radius: 8px; padding: 3px 5px; }
.signpreview .ppage .pnum { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.6); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 6px; z-index: 5; }
.signpreview .sigbox {
  position: absolute; border: 1px dashed var(--primary); background: rgba(139,92,246,0.12);
  border-radius: 10px; text-align: center; font-size: 20px; line-height: 1;
  cursor: grab; touch-action: none; user-select: none; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.signpreview .sigbox:active { cursor: grabbing; }
.signpreview .sigbox .siglive { width: 100%; height: auto; flex: 1 1 auto; display: block; pointer-events: none; border-radius: 8px; }
/* Label "Nama / Tanggal" mengalir ke dalam kotak, di bawah tanda tangan (mengikuti .signpad) */
.signpreview .sigbox .siglabel {
  width: 100%; flex: 0 0 auto;
  font-size: 12px; line-height: 1.2; color: var(--primary, #6366f1);
  text-align: center; padding: 2px 4px; word-break: break-word;
  background: rgba(255,255,255,0.55); border-radius: 0 0 8px 8px;
}
.signpreview .sigbox .siglabel:empty { display: none; }
.signpreview .sigbox .sigresize { position: absolute; right: -2px; bottom: -2px; width: 16px; height: 16px; background: #2563eb; border-radius: 3px; cursor: nwse-resize; touch-action: none; }
.signpreview .sigbox .sigrotate { position: absolute; left: -2px; top: -2px; width: 16px; height: 16px; background: #16a34a; color: #fff; font-size: 11px; line-height: 15px; text-align: center; border-radius: 3px; cursor: grab; touch-action: none; z-index: 2; }
.signpreview .sigbox .sigrotate:active { cursor: grabbing; }
.signbgctl { gap: 16px; flex-wrap: wrap; margin: 6px 0 4px; }
.signbgctl .sens { display: inline-flex; align-items: center; gap: 6px; }
.signbgctl input[type=range] { width: 120px; accent-color: var(--primary); }

/* ---------------- Scan crop editor ---------------- */
.scan-editor { display: flex; flex-direction: column; gap: 16px; margin: 8px 0 4px; }
#scanCropInfo:empty { display: none; margin: 0; padding: 0; }
#scanEditor { display: flex; flex-direction: row; gap: 16px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; position: relative; }
#scanEditor .cropeditor { flex: 0 0 auto; width: 100%; max-width: 100%; scroll-snap-align: center; margin: 0; }
.cropeditor.active-page { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow); }
.page-indicator { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.page-indicator .pnav { width: 30px; height: 30px; border: 1px solid var(--border); background: #fff; color: var(--primary); border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.08); transition: transform .12s, background .12s; }
.page-indicator .pnav:hover { background: var(--primary-soft); }
.page-indicator .pnav:active { transform: scale(.92); }
.page-indicator .pdots { display: flex; align-items: center; gap: 6px; }
.page-indicator .pdot { width: 9px; height: 9px; padding: 0; border: none; border-radius: 50%; background: #cbd5e1; cursor: pointer; transition: background .15s, transform .15s; }
.page-indicator .pdot.active { background: var(--primary); transform: scale(1.4); }
.page-indicator .pjump { width: 52px; font-size: 13px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; text-align: center; -moz-appearance: textfield; }
.page-indicator .pjump::-webkit-outer-spin-button, .page-indicator .pjump::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.page-indicator .pjump:focus { outline: 2px solid var(--primary-soft); }
.page-indicator .plabel { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cropeditor { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 12px; box-shadow: var(--shadow); }
.ceditor-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; position: relative; }
.ceditor-title { font-weight: 700; font-size: 14px; flex: 1; }
.ceditor-del {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 15px; cursor: pointer; line-height: 1; color: var(--danger);
}
.ceditor-del:hover { background: #fff5f5; border-color: #fecaca; }
.ceditor-rot {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 15px; cursor: pointer; line-height: 1; color: var(--text);
}
.ceditor-rot:hover { background: #f2f3fb; }
/* Pengaturan Proses + Kualitas PPI — DUA kartu terpisah (PPI bukan bagian OCR),
   kartu putih + aksen ungu, konsisten gaya .selcard & tombol .btn panel lain. */
.scan-settings { display: flex; flex-direction: column; gap: 12px; margin: 10px 0 12px; }
.scan-card { background: var(--surface, #fff); border: 1px solid var(--border, #e8e6f3); border-radius: 16px; padding: 4px 12px 8px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.ss-title { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted, #6b7280); padding: 12px 2px 6px; }
.opt-card { display: flex; align-items: center; gap: 11px; padding: 9px 4px 9px 2px; border-top: 1px solid var(--border, #e8e6f3); }
.scan-card .ss-title + .opt-card { border-top: none; }
.opt-ico { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft, #eef2ff); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.opt-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.opt-name { font-size: 14px; font-weight: 700; color: var(--text); }
.opt-sub { font-size: 11.5px; color: var(--muted, #6b7280); font-weight: 600; }
.opt-select { flex: 0 0 auto; height: 30px; padding: 0 10px; border: 1px solid var(--border, #e8e6f3); background: var(--primary-soft, #eef2ff); color: var(--text); border-radius: 11px; font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer; max-width: 46%; }
.opt-select:focus { outline: none; box-shadow: var(--ring); border-color: var(--primary); }
/* Desktop: panel 820px → baris opsi terlalu lebar, teks & sakelar berjauh
   (~600px) dan terlihat aneh. Batasi lebar isi kartu + rapatkan jarak
   meta↔kontrol. Mobile (<=760px) tetap 100% penuh — jangan diubah. */
@media (min-width: 761px) {
  .scan-settings { max-width: 560px; }
  .opt-card { gap: 10px; }
  /* meta TETAP flex:1 (default) → semua kontrol rata kanan sejajar kolom.
     Jangan ubah ke flex:0 — itu yg bikin tepi kanan kontrol berantakan. */
  .ppi-group { gap: 8px; }
}
/* Sakelar modern pengganti checkbox telanjang.
   PENTING: selector WAJIB `input[type=checkbox]` — aturan global
   `input[type=checkbox]{width:16px}` di bawah file punya spesifikasi sama
   (0-1-1) dgn `.switch input`, jadi kalau kalah urutan, track menyusut ke
   16px & knob 21px nyembul keluar (bug: toggle tampak rusak/terpotong). */
.switch { position: relative; flex: 0 0 auto; display: inline-flex; }
.switch input[type="checkbox"] { appearance: none; -webkit-appearance: none; margin: 0; width: 46px; height: 27px; border-radius: 999px; background: #d8dae8; position: relative; cursor: pointer; transition: background .18s; }
.switch input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .18s; }
.switch input[type="checkbox"]:checked { background: var(--grad, #6366f1); box-shadow: 0 4px 10px rgba(139, 92, 246, .35); }
.switch input[type="checkbox"]:checked::after { left: 22px; }
/* Kartu pilihan PPI — baris sendiri di bawah, TERPISAH dari OCR */
.ppi-group { display: flex; gap: 9px; padding: 4px 2px 10px; }
.ppi-opt { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px; border-radius: 14px; border: 1.5px solid var(--border, #e8e6f3); background: #fff; cursor: pointer; font-family: inherit; transition: border-color .15s, background .15s, transform .1s, box-shadow .15s; }
.ppi-opt b { font-size: 17px; font-weight: 800; color: var(--text); line-height: 1.15; }
.ppi-opt small { font-size: 11px; font-weight: 700; color: var(--muted, #6b7280); }
.ppi-opt:active { transform: scale(.97); }
.ppi-opt.active { border-color: transparent; background: #f5f3ff; box-shadow: inset 0 0 0 2px var(--primary, #8b5cf6); }
.ppi-opt.active b, .ppi-opt.active small { color: #6d28d9; }
.ceditor-stage { position: relative; margin: 0 auto; touch-action: none; user-select: none; }
.ceditor-canvas { display: block; border-radius: 10px; }
.ceditor-overlay { position: absolute; left: 0; top: 0; pointer-events: none; }
.cropeditor .ceditor-handle { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; background: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: grab; touch-action: none; }
.cropeditor .ceditor-handle:active { cursor: grabbing; }
.cropeditor .ceditor-ctrls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 10px; border-top: 1px solid var(--border); background: #f8fafc;
  font-size: 12px; color: var(--text); margin-top: 10px; border-radius: 0 0 12px 12px;
}
.cropeditor .ceditor-angle { flex: 1; min-width: 120px; accent-color: var(--primary); }
.cropeditor .ceditor-angle-num { width: 62px; font-size: 12px; padding: 3px 5px; border: 1px solid var(--border); border-radius: 8px; text-align: center; }
.cropeditor .ceditor-angle-num:focus { outline: 2px solid var(--primary-soft); }
.cropeditor .ceditor-angle-out { min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.cropeditor .ceditor-shadow { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }

/* ---------------- File list / thumbs ---------------- */
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.thumb { position: relative; }
.thumb img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.thumb .mini { position: absolute; top: -6px; right: -6px; border-radius: 999px; padding: 0 6px; line-height: 18px; background: #fff; }
.filelist { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.frow { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: #fff; box-shadow: var(--shadow); transition: transform .1s; }
.frow:hover { transform: translateY(-1px); }
.frow.result { border-left: 4px solid var(--ok); }
.frow.original { border-left: 4px solid #94a3b8; }
.fmeta { display: flex; flex-direction: column; min-width: 0; }
.fname { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.fsub { font-size: 12px; color: var(--muted); }
.factions { display: flex; gap: 6px; flex-shrink: 0; }
.empty { color: var(--muted); font-size: 14px; padding: 28px; text-align: center; border: 1px dashed var(--border); border-radius: 14px; }

/* ---------------- Status ---------------- */
.status { margin-top: 16px; padding: 12px 16px; border-radius: 14px; font-size: 14px; display: none; font-weight: 600; }
.status.info { background: var(--primary-soft); color: var(--primary-dark); }
.status.ok { background: var(--ok-soft); color: #047857; }
.status.err { background: var(--danger-soft); color: #b91c1c; }
/* Snackbar notifikasi (menggantikan status box lama) */
#status.status {
  position: fixed; left: 16px; right: 16px; z-index: 10000;
  bottom: calc(70px + env(safe-area-inset-bottom)); /* di atas bottom-nav 58px */
  display: none; margin: 0; padding: 15px 18px 15px 16px;
  border-radius: 18px; background: var(--snack, #1e1b4b); color: #fff;
  font-size: 14px; font-weight: 600; line-height: 1.45;
  box-shadow: 0 12px 34px rgba(10,8,30,.45);
  align-items: center; gap: 12px;
}
#status.status.show { display: flex; }
#status.status.pop { animation: snackUp .25s ease; }
@keyframes snackUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
#status.status::before {
  content: "i"; flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 999px; font-weight: 900; font-size: 15px; font-style: normal;
  background: rgba(255,255,255,.16); color: #fff;
}
#status.status.ok::before { content: "✓"; background: var(--ok, #10b981); }
#status.status.err::before { content: "!"; background: var(--danger, #ef4444); }
@media (min-width: 761px) {
  #status.status { left: auto; right: 24px; bottom: 24px; width: min(420px, 90vw); }
}

/* ---------------- Footer ---------------- */
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 22px; }

/* ---------------- Modal (native video capture) ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; z-index: 50; padding: 16px;
  animation: fadeUp .2s ease;
}
.modal video { max-width: 100%; max-height: 70vh; border-radius: 16px; background: #000; box-shadow: var(--shadow-lg); }
.modal-actions { display: flex; gap: 12px; }

/* ---------------- Convert ---------------- */
/* Kartu file terunggah — daftar per file (ikon tipe + nama + ukuran + hapus) */
.selname { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 2px; }
.selname:empty { margin: 0; gap: 0; }
.selcard { display: flex; align-items: center; gap: 10px; background: var(--surface, #fff); border: 1px solid var(--border, #e5e7f0); border-radius: 14px; padding: 9px 10px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); animation: fadeUp .18s ease; }
.selcard-ico { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; background: #f1f5f9; }
.selcard-ico.fam-pdf { background: #fee2e2; }
.selcard-ico.fam-doc { background: #dbeafe; }
.selcard-ico.fam-sheet { background: #dcfce7; }
.selcard-ico.fam-slide { background: #ffedd5; }
.selcard-ico.fam-img { background: #ede9fe; }
.selcard-ico.fam-web { background: #ccfbf1; }
.selcard-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.selcard-name { font-size: 13.5px; font-weight: 700; color: var(--text, #1f2430); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selcard-sub { font-size: 11.5px; color: var(--muted, #6b7280); font-weight: 600; letter-spacing: .02em; }
.selcard-x { flex: 0 0 auto; width: 30px; height: 30px; border: 1px solid var(--border, #e5e7f0); border-radius: 10px; background: #fff; color: #64748b; font-size: 14px; line-height: 1; cursor: pointer; padding: 0; }
.selcard-x:hover { border-color: #ef4444; color: #ef4444; background: #fef2f2; }
.conv-sel { display: flex; align-items: flex-end; gap: 12px; margin: 8px 0 16px; }
.conv-sel .fmtbox { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.conv-sel .fmtbox label { font-size: 12px; color: var(--muted); font-weight: 700; }
.conv-sel select { width: 100%; padding: 11px 12px; border-radius: 11px; }
.swbtn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  width: 44px; height: 42px; font-size: 18px; cursor: pointer; color: var(--text);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; padding: 0;
  transition: background .15s, color .15s, transform .1s;
}
.swbtn svg { width: 18px; height: 18px; display: block; color: var(--text); }
.swbtn:hover { background: var(--grad); border-color: var(--primary); color: #fff; transform: rotate(180deg); }
.swbtn:hover svg { color: #fff; }
.dropzone { width: 100%; text-align: center; padding: 26px 18px; border-style: dashed; border-width: 2px; border-color: var(--border); background: linear-gradient(180deg, #fafaff, #f3f0ff); }
.dropzone:hover { border-color: var(--primary); }
.dropzone.drag { border-color: var(--accent); background: var(--primary-soft); }
/* Sorot panel saat file di-drag ke dalamnya (drag & drop per fitur) */
.panel.dropover { outline: 2.5px dashed var(--primary); outline-offset: -6px; }

/* ---------------- Merge ---------------- */
.merge-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.mrow { display: flex; align-items: center; gap: 10px; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.mrow .mname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moves { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.moves button { width: 30px; height: 22px; line-height: 1; padding: 0; font-size: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); cursor: pointer; color: var(--text); }
.moves button:disabled { opacity: .35; cursor: default; }
.mrange { width: 92px !important; }
.mdel { margin-left: 4px; width: 28px; height: 28px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--danger); cursor: pointer; font-size: 14px; line-height: 1; }
.mdel:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------------- Misc ---------------- */
input[type=range] { accent-color: var(--primary); cursor: pointer; }
input[type=checkbox] { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }
label { cursor: pointer; }

/* ---------------- Mobile bottom navigation (YouTube-style) ---------------- */
.bottomnav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  align-items: stretch; justify-content: space-around;
  height: 58px; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
}
.bottomnav .bnitem {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 10px; font-weight: 600; padding: 0;
  transition: color .15s;
}
.bottomnav .bnico { font-size: 20px; line-height: 1; }
.bottomnav .bnlbl { line-height: 1.1; }
.bottomnav .bnitem.active { color: var(--primary); text-shadow: 0 1px 10px rgba(139, 92, 246, 0.3); }
.bottomnav .bnitem.active .bnico { transform: translateY(-1px); filter: drop-shadow(0 2px 6px rgba(139, 92, 246, 0.5)); }

@media (max-width: 760px) {
  .tabs { display: none; }
  .bottomnav { display: flex; }
  .container { padding-bottom: 76px; }
  .footer { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ============================================================
   Language switch — mobile FAB + desktop pill
   The header (.feature-topbar) is hidden below 760px, so mobile needs
   its own always-visible control. Desktop keeps the header pill.
   ============================================================ */
.langfab {
  position: fixed;
  right: 14px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border: 1px solid var(--border, #e8e6f3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.16);
  color: var(--primary-dark, #4f46e5);
  font: 700 12px/1 var(--font, system-ui);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.langfab:active { transform: scale(0.96); }
.langfab-ico { font-size: 15px; line-height: 1; }
.langfab-lbl { letter-spacing: 0.4px; }
@media (min-width: 761px) { .langfab { display: none; } }

.lang-menu {
  position: fixed;
  z-index: 61;
  right: 14px;
  bottom: calc(116px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-width: 156px;
  padding: 6px;
  border: 1px solid var(--border, #e8e6f3);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
  animation: langPop .14s ease-out;
}
body[data-tab="home"] .lang-menu { bottom: calc(116px + env(safe-area-inset-bottom)); }
.lang-menu[hidden] { display: none; }
@keyframes langPop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.lang-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink, #1c2033);
  font: 600 13px/1 var(--font, system-ui);
  text-align: left;
  cursor: pointer;
}
.lang-menu-item:hover { background: #f2f3fb; }
.lang-menu-item[aria-checked="true"] { background: var(--primary-soft, #eef2ff); color: var(--primary-dark, #4f46e5); }
.lang-menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; font-weight: 800; }

.lang-toaster {
  position: fixed;
  z-index: 62;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(130px + env(safe-area-inset-bottom));
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  font: 600 12.5px/1.35 var(--font, system-ui);
  text-align: center;
  max-width: 82vw;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
  animation: langPop .16s ease-out;
}
.lang-toaster[hidden] { display: none; }


/* ---------------- Responsive ---------------- */
@media (max-width: 560px) {
  .topbar { padding: 12px 14px; }
  .topbar h1, .topbar .brandname { font-size: 18px; }
  .container { padding: 16px 12px 76px; }
  .panel { padding: 18px; }
  /* Scan panel: gunakan lebar layar penuh (batalkan padding .container) */
  #panel-scan { margin: 0 -12px; padding: 0; }
  #panel-scan .scanui { padding: 0 10px; }
  #panel-scan .scan-stage { padding: 0; }
  .fname { max-width: 180px; }
  .btn.primary { padding: 13px; }
}

/* ---------- PROCESSING OVERLAY (progress bar) ---------- */
.proc-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; z-index: 9999; }
.proc-overlay.show { display: flex; animation: procFade .2s ease; }
@keyframes procFade { from { opacity: 0; } to { opacity: 1; } }
.proc-card { position: relative; width: min(86vw, 320px); background: #fff; border-radius: 18px; padding: 20px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25); text-align: center; }
.proc-close { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; color: #94a3b8; font-size: 18px; line-height: 1; padding: 6px 8px; cursor: pointer; border-radius: 999px; }
.proc-close:hover { color: #334155; background: #f1f5f9; }
.proc-label { font-weight: 700; font-size: 15px; color: #0f172a; margin-bottom: 14px; }
.proc-bar { height: 8px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.proc-fill { height: 100%; width: 30%; border-radius: 99px; background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899); transition: width .3s ease; }
.proc-fill.indeterminate { width: 30%; animation: procIndet 1.1s ease-in-out infinite; }
@keyframes procIndet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.proc-sub { margin-top: 10px; font-size: 12px; color: #64748b; }
.proc-icon { font-size: 34px; line-height: 1; margin-bottom: 6px; color: #16a34a; display: none; }
.proc-overlay.done .proc-icon { display: block; }
.proc-overlay.done .proc-bar { display: none; }
.proc-overlay.done .proc-sub { margin-top: 6px; }
.proc-btn { margin-top: 16px; padding: 11px 20px; border: none; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(139,92,246,.4); transition: transform .12s; }
.proc-btn:active { transform: scale(.96); }

/* ---------- SEO content (crawlable feature descriptions) ---------- */
.seo-content { margin-top: 8px; }
.seo-content .container { max-width: 820px; margin: 0 auto; padding: 26px 18px 40px; }
.seo-content h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 12px; background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899); -webkit-background-clip: text; background-clip: text; color: transparent; }
.seo-content h3 { font-size: 17px; font-weight: 700; margin: 22px 0 6px; color: var(--text); }
.seo-content p { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 0 0 8px; }
.seo-content .seo-keywords { font-size: 12.5px; color: #9aa0b4; margin-top: 18px; }
.btn-row { display: flex; gap: 12px; margin-top: 2px; }
.btn-row .btn { flex: 1 1 0; width: auto; margin-top: 0; padding: 14px; font-size: 15px; height: 50px; box-sizing: border-box; justify-content: center; }
.btn-row .btn.primary { flex: 1 1 0; width: auto; margin-top: 0; }
.btn.ghost { background: #e2e8f0; color: #334155; border: 1px solid #cbd5e1; }
.btn.ghost:hover { background: #cbd5e1; }

/* ===== Scan UI ala reader/viewer ===== */
.scanui { display: flex; flex-direction: column; gap: 12px; }
.scan-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #1c2033; color: #fff; border-radius: 14px; padding: 10px 14px;
}
.scan-toolbar .st-title { font-weight: 800; font-size: 15px; }
.scan-toolbar .st-right { display: flex; gap: 8px; }
.tbtn {
  min-width: 36px; height: 36px; border-radius: 10px; border: 0; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tbtn:active { transform: scale(.94); }
.tbtn.off { opacity: .45; }
.scan-stage {
  background: #23273b; border-radius: 14px; min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px;
  position: relative;
}
.scan-stage.dragover { outline: 3px dashed #6366f1; outline-offset: -6px; background: #2a2f4a; }
/* Kartu putih di dalam stage gelap ( Sign PDF meniru editor Scan ) */
.signcard {
  width: 100%; background: #fff; border-radius: 12px; padding: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.22); color: var(--ink);
}
.signcard .signpad { max-width: none; } /* ikuti lebar kartu */
/* Tombol toolbar/navigator dengan teks (bukan cuma ikon) */
.tbtn.has-text { width: auto; padding: 0 14px; gap: 6px; font-size: 14px; font-weight: 600; }
/* Tombol Konfirmasi: kontras tinggi (warna penuh) */
.confirm-btn {
  background: var(--primary, #6366f1); color: #fff; border: 0; font-weight: 700;
  border-radius: 10px; padding: 9px 16px; cursor: pointer; font-size: 14px;
}
.confirm-btn:active { transform: scale(.97); }
/* Desktop: drop hint + cursor saat kosong */
@media (min-width: 761px) {
  .scan-stage { cursor: default; }
  .scan-empty .se-drop { display: block; margin-top: 10px; font-size: 13px; color: #8b93b8; }
  .scan-stage:not(.has-image) { cursor: copy; }
}
/* Scan: card/stage mengikuti lebar layar penuh (batalkan .container max-width 820px) */
#panel-scan {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  padding: 0;
}
#panel-scan .scanui { padding: 0 10px; }
#panel-scan .scan-stage { width: 100%; padding: 10px; box-sizing: border-box; }
#panel-scan .signcard { width: 100%; }
/* Sign: card/stage mengikuti lebar layar penuh (sama seperti Scan) */
#panel-sign {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  padding: 0;
}
#panel-sign .scanui { padding: 0 10px; }
#panel-sign .scan-stage { width: 100%; padding: 10px; box-sizing: border-box; }
#panel-sign .signcard { width: 100%; }
/* Tombol "Pilih PDF" di Sign diperkecil lebarnya (padding & font lebih kecil) */
#signAddBtn.signpick-inline { padding: 0 10px; font-size: 13px; min-width: 0; height: 32px; }
@media (max-width: 760px) {
  .scan-empty .se-drop { display: none; }
}
.scan-empty { width: 100%; flex: 1; min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #aab; }
.scan-empty .se-ico { font-size: 44px; margin-bottom: 6px; }
#scanEditor { width: 100%; }
.scan-pagenav {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: #fff; background: #1c2033; border-radius: 12px; padding: 6px 10px;
  margin-bottom: 4px;
}
.scan-pagenav.empty #scanAddBtn {
  background: var(--brand, #6366f1); color: #fff; font-size: 18px; width: 44px; height: 44px;
}
/* Sign: saat preview kosong, sembunyikan prev/next/label (tombol Pilih PDF tetap lebar) */
#signPageNav.empty #signPrev,
#signPageNav.empty #signNext,
#signPageNav.empty .pn-lbl { display: none; }
/* Tombol Pilih PDF inline di navigator: diperkecil lebarnya (padding & font lebih kecil) */
#signPageNav #signAddBtn {
  width: auto;
  min-width: 0;
  max-width: 70vw;
  height: auto;
  padding: 7px 12px;
  line-height: 1.2;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--brand, #6366f1);
  color: #fff;
}
.signpick-inline:active { transform: scale(.97); }
/* Textbox Nama/Tanggal inline di kanan baris Unggah gambar, lebar mengikuti signpad */
.signlabel-inline {
  flex: 1 1 auto;
  min-width: 120px;
  padding: 9px 12px;
  border: 1px solid #d3d6e4;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.scan-pagenav .pn-lbl input {
  width: 46px; text-align: center; border: 0; border-radius: 8px;
  padding: 4px; font-size: 14px;
}
.scan-addwrap { position: relative; display: inline-flex; margin-left: 8px; }
.scan-addbar .tbtn.primary {
  background: var(--brand, #6366f1); color: #fff; font-weight: 700; font-size: 15px;
  padding: 0 18px; height: 42px;
}
.scan-addmenu {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  min-width: 180px; background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 6px; display: none; flex-direction: column; gap: 2px;
}
.scan-addmenu.open { display: flex; }
.scan-addmenu .sam-item {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  border: 0; background: #fff; color: var(--text); font-size: 14px; cursor: pointer;
}
.scan-addmenu .sam-item:hover { background: #f2f3fb; }
.scan-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.scan-modes .chip {
  flex: 1; padding: 9px 12px; border-radius: 999px; border: 2px solid transparent;
  background: #eef0ff; color: #3a3f5c; font-weight: 700; font-size: 13px; cursor: pointer;
}
.scan-modes .chip.active { background: var(--brand, #6366f1); color: #fff; }
.scan-toggles { display: flex; gap: 16px; font-size: 14px; color: #3a3f5c; }
.scan-toggles .tg { display: flex; align-items: center; gap: 6px; }
.scan-actions { display: flex; gap: 10px; }
.scan-actions .big {
  flex: 1; padding: 13px; border-radius: 14px; border: 0; cursor: pointer;
  font-size: 15px; font-weight: 800; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.scan-actions .big.primary { background: var(--brand, #6366f1); color: #fff; }
.scan-actions .big.ghost { background: #eef0ff; color: #3a3f5c; }

/* Tombol Home di halaman fitur (pengganti header topbar) */
.homebtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 12px; text-decoration: none;
  background: #eef0ff; font-size: 18px; flex: 0 0 auto;
}
.tabwrap { display: flex; align-items: center; gap: 6px; }

/* ---------- Bottom-nav drawer (Lainnya: Merge/Convert) + Home item ---------- */
.bottomnav .bn-home { text-decoration: none; }
.bottomnav .bn-more .bnico { font-weight: 900; letter-spacing: 1px; }
.nav-drawer {
  position: fixed; left: 10px; right: 10px; bottom: 66px; z-index: 60;
  background: #fff; border-radius: 16px; padding: 6px;
  box-shadow: 0 -6px 32px rgba(28,32,51,.18);
  display: none; flex-direction: column;
}
.nav-drawer.open { display: flex; animation: drawerUp .16s ease; }
@keyframes drawerUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.nav-drawer .drawer-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border: 0; background: transparent; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-weight: 700; color: var(--ink, #1c2033); text-align: left;
}
.nav-drawer .drawer-item:hover { background: #f2f3fb; }
.nav-drawer .di-ico { font-size: 20px; }

/* ---------- Header desktop-only di halaman fitur (mobile = tanpa header) ---------- */
.feature-topbar { display: flex; }
@media (max-width: 760px) {
  .feature-topbar { display: none; }
}

/* Tab Home = tab biasa (style identik); netralisasi default tag <a> */
a.tab { text-decoration: none; display: inline-block; font-family: var(--font, inherit); }

/* Slider putar bebas global (semua halaman) */
.scan-freerot {
  display: flex; align-items: center; gap: 10px;
  background: #f2f3fb; border-radius: 12px; padding: 10px 14px; font-size: 14px;
}
.scan-freerot input[type="range"] { flex: 1; accent-color: var(--primary); }
.freerot-ctrl { display: flex; align-items: center; gap: 6px; flex: 1; }
.freerot-ctrl .tbtn { min-width: 38px; padding: 6px 8px; font-size: 13px; }
.freerot-ctrl input[type="range"] { flex: 1; }
/* Handle label yang bisa di-drag bebas di atas area tanda tangan (.signpad) — transparan */
.signpad-wrap .sign-label-handle {
  position: absolute; z-index: 5; padding: 3px 8px; border-radius: 6px;
  background: transparent; color: transparent; font-size: 12px; line-height: 1.2;
  cursor: grab; user-select: none; touch-action: none; white-space: nowrap;
  box-shadow: none; pointer-events: auto; border: 0;
}
.signpad-wrap .sign-label-handle:active { cursor: grabbing; }
