:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e5e8ee;
  --border-strong: #d4dae3;
  --text: #0f172a;
  --text-muted: #5b6472;
  --text-faint: #6b7280;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-soft: #eef4ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --stage: #e9ebef;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 500;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

button, input, select { font-family: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============ Header ============ */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-link { color: inherit; text-decoration: none; }
.brand-link:hover .brand-title { color: var(--primary); }
.header-home {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.header-home:hover { color: var(--primary); background: var(--primary-soft); }
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text .brand-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.tagline { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }

/* ============ Tabs ============ */
.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 4px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab svg { width: 17px; height: 17px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab.active svg { color: var(--primary); }

/* ---------- Grouped navigation ---------- */
.nav-primary {
  gap: 6px;
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-primary::-webkit-scrollbar { display: none; }
.nav-sub {
  gap: 6px;
  padding-top: 10px;
  padding-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-sub::-webkit-scrollbar { display: none; }
.nav-sub-group { display: flex; gap: 6px; }
.nav-sub-group[hidden] { display: none; }

.nav-cat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-cat svg { width: 16px; height: 16px; }
.nav-cat:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.nav-cat.active { background: var(--primary-soft); color: var(--primary); border-color: #cfe0ff; }

.nav-sub .tab {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-sub .tab svg { width: 15px; height: 15px; }
.nav-sub .tab:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.nav-sub .tab.active { background: var(--primary-soft); color: var(--primary); border-color: #cfe0ff; }
.nav-sub .tab.active svg { color: var(--primary); }

/* ---------- Sidebar navigation (desktop) ---------- */
.nav-sidebar-head { display: none; }
.nav-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.nav-search { position: relative; }
.nav-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.nav-search input {
  width: 100%;
  padding: 9px 10px 9px 33px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.nav-search input::placeholder { color: var(--text-faint); }
.nav-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.nav-count { display: none; }
.nav-empty {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 12px 10px;
}

/* ============ Layout ============ */
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 24px 40px; }

.panel { display: none; animation: fadeIn 0.18s ease; scroll-margin-top: 120px; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============ Page header ============ */
.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.page-head-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.page-head-icon svg { width: 22px; height: 22px; }
.page-head-text { min-width: 0; }
.page-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.page-desc { font-size: 13.5px; color: var(--text-muted); margin-top: 2px; }

.hidden { display: none !important; }

/* ============ Dropzone ============ */
.dropzone {
  border: 2px dashed var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.dz-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dz-icon svg { width: 30px; height: 30px; }
.dz-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.dz-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.4);
}
.btn-primary:hover { background: var(--primary-600); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-faint); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #fca5a5; }

.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ============ Cards ============ */
.file-list, .scan-workspace, .compress-workspace, .unlock-workspace, .protect-workspace, .tool-workspace {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.list-header h2 { font-size: 16px; font-weight: 700; }
.badge {
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
  margin-left: 4px;
}
.list-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Merge list ============ */
.items { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.item.dragging { opacity: 0.5; }
.item .order {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.item .file-icon {
  color: var(--primary);
  display: flex;
  flex-shrink: 0;
}
.item .file-icon svg { width: 22px; height: 22px; }
.item .file-info { flex: 1; min-width: 0; }
.item .file-name {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item .file-meta { font-size: 12px; color: var(--text-muted); }
.item .item-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.merge-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.merge-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.merge-hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.merge-mode { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 220px; }
.merge-mode span { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.merge-mode select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.merge-mode select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.item-range { flex-shrink: 0; }
.item-range input {
  width: 130px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.item-range input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.page-range input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

/* ============ Editor ============ */
.editor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 232px);
  min-height: 520px;
  background: var(--stage);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-sep { width: 1px; height: 24px; background: var(--border); margin: 0 6px; }
.tb-spacer { flex: 1; }
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: none; background: transparent;
  border-radius: 8px; cursor: pointer;
  color: var(--text-muted); font-size: 16px; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.tb-btn:hover { background: var(--surface-2); color: var(--text); }
.tb-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tb-btn svg { width: 18px; height: 18px; }
.tb-btn.tb-danger:hover { background: var(--danger-soft); color: var(--danger); }
.tb-btn.active { background: var(--primary); color: #fff; }
.tb-btn.active:hover { background: var(--primary); color: #fff; }
.tb-zoom-label {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  padding: 0 6px; min-width: 42px; text-align: center;
  border-radius: 8px; height: 34px;
}
.tb-zoom-label:hover { background: var(--surface-2); color: var(--text); }
.page-indicator { font-size: 13px; color: var(--text-muted); white-space: nowrap; margin: 0 8px; }

.object-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--primary-soft);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.object-toolbar select,
.object-toolbar input[type="number"] {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13px;
  background: var(--surface); color: var(--text);
}
.object-toolbar select:focus, .object-toolbar input:focus { outline: none; border-color: var(--primary); }
.object-toolbar input[type="color"] { width: 40px; height: 34px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }
.object-toolbar input[type="range"] { accent-color: var(--primary); }
.tb-toggle.active { background: var(--primary); color: #fff; }
.ot-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.ot-val { font-size: 13px; color: var(--text-muted); min-width: 40px; }

.editor-body { display: flex; flex: 1; min-height: 0; }

.pages-sidebar {
  width: 150px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-title {
  font-size: 11px; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0 2px;
}
.pages-list { display: flex; flex-direction: column; gap: 8px; }
.page-item {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.page-item:hover { border-color: var(--border-strong); }
.page-item.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15); }
.page-item-thumb {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 84px;
  box-shadow: var(--shadow-sm);
}
.page-item-thumb canvas { width: 100%; height: auto; display: block; }
.page-item-label { font-size: 11px; color: var(--text-muted); margin-top: 5px; text-align: center; font-weight: 600; }
.page-item-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--danger); color: #fff;
  border: none; cursor: pointer; font-size: 12px; line-height: 1;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.page-item:hover .page-item-del { display: flex; }
.page-item-dup {
  position: absolute; top: 4px; left: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border-strong); cursor: pointer; font-size: 13px; line-height: 1;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.page-item:hover .page-item-dup { display: flex; }
.page-item-dup:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.editor-stage {
  flex: 1;
  overflow: auto;
  padding: 28px;
  background: var(--stage);
}
.page-holder { margin: 0 auto; }
.page-wrap {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-lg);
  transform-origin: top left;
}
.page-wrap canvas { display: block; }
.overlay-layer { position: absolute; inset: 0; }
.grid-layer {
  position: absolute; inset: 0; pointer-events: none; display: none;
  background-image:
    linear-gradient(to right, rgba(37, 99, 235, 0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 99, 235, 0.12) 1px, transparent 1px);
}
.grid-layer.visible { display: block; }

.overlay { position: absolute; cursor: move; touch-action: none; }
.overlay.selected { outline: 2px solid var(--primary); }
.overlay-img .obj-img {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.resize-handle {
  position: absolute; right: -7px; bottom: -7px;
  width: 15px; height: 15px;
  background: #fff; border: 2px solid var(--primary);
  border-radius: 4px; cursor: nwse-resize; display: none;
  box-shadow: var(--shadow-sm);
}
.overlay.selected .resize-handle { display: block; }
.obj-delete {
  position: absolute; top: -13px; right: -13px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--danger); color: #fff;
  border: none; cursor: pointer; font-size: 12px; line-height: 1;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.overlay.selected .obj-delete { display: flex; }

.overlay-text { line-height: 1.2; }
.overlay-text .obj-text { white-space: pre-wrap; cursor: move; outline: none; }
.overlay-text .obj-text[contenteditable="true"] { outline: 1px dashed var(--primary); cursor: text; }

.overlay-shape { overflow: visible; }
.overlay-shape .obj-shape-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; display: block; }
.overlay-shape#draw-preview { pointer-events: none; }
.editor-stage.drawing { cursor: crosshair; }

/* ============ Scan ============ */
.scan-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.scan-controls .field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.scan-controls .field span { font-weight: 600; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.scan-controls .field b { color: var(--primary); font-weight: 700; }
.scan-controls select {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface); color: var(--text);
}
.scan-controls select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.scan-controls input[type="range"] { accent-color: var(--primary); height: 28px; }
.scan-preview { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.scan-preview-title { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.scan-preview-box {
  background: var(--stage);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  justify-content: center;
  min-height: 140px;
}
.scan-preview-box canvas {
  max-width: 100%;
  max-height: 480px;
  background: #fff;
  box-shadow: var(--shadow-md);
}
.scan-workspace .btn { align-self: flex-start; }

/* ============ Compress ============ */
.compress-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.compress-controls .field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.compress-controls .field span { font-weight: 600; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.compress-controls .field b { color: var(--primary); font-weight: 700; }
.compress-controls select {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface); color: var(--text);
}
.compress-controls select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.compress-controls input[type="number"] {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface); color: var(--text); width: 100%; box-sizing: border-box;
}
.compress-controls input[type="number"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.compress-controls input[type="range"] { accent-color: var(--primary); height: 28px; }
.compress-note { font-size: 13px; color: var(--text-muted); }
.compress-warning {
  font-size: 13px;
  color: var(--text);
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.45);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.font-warning {
  color: var(--danger);
  font-weight: 600;
}
.compress-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.compress-info .stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.compress-info .stat span { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.compress-info .stat b { font-size: 20px; font-weight: 700; }
.compress-workspace .btn { align-self: flex-start; }

/* ============ Form Fill ============ */
.formfill-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.formfill-list:empty { display: none; }
.formfill-row {
  display: grid;
  grid-template-columns: minmax(150px, 240px) minmax(0, 1fr);
  gap: 10px 18px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.formfill-label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.formfill-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}
.formfill-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.formfill-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}
.formfill-badge.locked { background: var(--danger-soft); color: var(--danger); }
.formfill-control { display: flex; align-items: center; gap: 8px; min-width: 0; }
.formfill-control input[type="text"],
.formfill-control input[type="password"],
.formfill-control textarea,
.formfill-control select {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.formfill-control textarea { min-height: 64px; resize: vertical; }
.formfill-control select[multiple] { min-height: 78px; }
.formfill-control input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
.formfill-control input:focus,
.formfill-control textarea:focus,
.formfill-control select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.formfill-control input:disabled,
.formfill-control textarea:disabled,
.formfill-control select:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}
.formfill-static { font-size: 13px; color: var(--text-muted); }

@media (max-width: 640px) {
  .formfill-row { grid-template-columns: minmax(0, 1fr); }
}

/* ============ Unlock ============ */
.unlock-workspace { display: flex; flex-direction: column; gap: 16px; }
.unlock-status {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
}
.unlock-workspace .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.unlock-workspace .field span { font-weight: 600; color: var(--text); }
.unlock-workspace .field input {
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px;
  background: var(--surface); color: var(--text);
}
.unlock-workspace .field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.unlock-workspace .btn { align-self: flex-start; }

/* ============ Protect ============ */
.protect-workspace { display: flex; flex-direction: column; gap: 16px; }
.protect-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-items: start;
}
.protect-workspace .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.protect-workspace .field span { font-weight: 600; color: var(--text); }
.protect-workspace .field input {
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px;
  background: var(--surface); color: var(--text);
}
.protect-workspace .field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.protect-perms { display: flex; flex-direction: column; gap: 8px; }
.perms-title { font-size: 13px; font-weight: 600; color: var(--text); }
.protect-perms .check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.protect-perms .check input { accent-color: var(--primary); width: 16px; height: 16px; }
.protect-note { font-size: 13px; color: var(--text-muted); }
.protect-workspace .btn { align-self: flex-start; }

/* ============ Tools (Rotate / Crop / Organize) ============ */
.tool-workspace { display: flex; flex-direction: column; gap: 20px; }
.tool-controls { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.tool-controls .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.tool-controls .field span { font-weight: 600; color: var(--text); }
.tool-controls select,
.tool-controls input[type="number"] {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface); color: var(--text);
}
.tool-controls select:focus,
.tool-controls input[type="number"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.tool-controls input[type="number"] { width: 90px; }
.tool-workspace .btn { align-self: flex-start; }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}
.thumb-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.thumb-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.thumb-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.thumb-card.dragging { opacity: 0.5; }
.thumb-canvas {
  position: relative;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  min-height: 150px;
  overflow: hidden;
}
.thumb-canvas canvas { width: 100%; height: auto; display: block; }
.thumb-num {
  position: absolute; top: 6px; left: 6px;
  background: rgba(15, 23, 42, 0.62); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 7px;
}
.thumb-actions {
  display: flex; gap: 4px; padding: 8px; justify-content: center; flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.thumb-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
  border-radius: 6px; width: 28px; height: 28px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.thumb-btn:hover { background: var(--border); color: var(--text); }
.thumb-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.organize-hint { font-size: 13px; color: var(--text-muted); }

.crop-preview { display: flex; flex-direction: column; gap: 8px; }
.crop-preview-title { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.crop-preview-box {
  background: var(--stage); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; display: flex; justify-content: center; min-height: 140px;
}
.crop-preview-wrap { position: relative; display: inline-block; line-height: 0; }
.crop-preview-wrap canvas { max-width: 100%; max-height: 420px; box-shadow: var(--shadow-md); }
.crop-shade { position: absolute; background: rgba(15, 23, 42, 0.45); pointer-events: none; }

/* ============ URL Shortener ============ */
.shortener-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 640px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.shortener-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.shortener-form .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.shortener-form .field span { font-weight: 600; color: var(--text); }
.shortener-form .field input {
  padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px;
  background: var(--surface); color: var(--text);
}
.shortener-form .field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.shortener-form .btn { align-self: flex-start; }
.shorten-result {
  margin-top: 22px;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  text-align: left; flex-wrap: wrap;
}
.shorten-result span { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.shorten-result a { color: var(--primary); font-weight: 600; text-decoration: none; word-break: break-all; flex: 1; min-width: 0; }
.shorten-result a:hover { text-decoration: underline; }

/* ============ Utility Tools (QR / Password / Word Count / Image) ============ */
.utility-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 900px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.utility-card.single { display: flex; flex-direction: column; gap: 18px; }
.utility-card.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.utility-form { display: flex; flex-direction: column; gap: 16px; text-align: left; min-width: 0; }
.utility-form .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.utility-form .field > span { font-weight: 600; color: var(--text); }
.utility-form .field b { color: var(--primary); font-weight: 700; }
.utility-form input[type="text"],
.utility-form input[type="number"],
.utility-form select,
.utility-form textarea {
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
.utility-form textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
.utility-form input[type="text"]:focus,
.utility-form input[type="number"]:focus,
.utility-form select:focus,
.utility-form textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.utility-form input[type="color"] {
  width: 100%; height: 42px; padding: 3px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.utility-form input[type="range"] { width: 100%; accent-color: var(--primary); }
.utility-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
}
.utility-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.utility-actions .btn { align-self: flex-start; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.qr-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 280px;
  padding: 22px;
  background: var(--stage);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}
.qr-preview canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  background: #fff;
}
.qr-empty { font-size: 13.5px; color: var(--text-muted); max-width: 220px; }
.qr-meta { font-size: 12px; color: var(--text-faint); font-weight: 600; }

.qr-logo {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.qr-logo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.qr-logo-title { font-weight: 600; color: var(--text); }
.qr-logo-optional {
  margin-left: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.qr-logo-name {
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-faint);
}
.qr-logo-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qr-logo-thumb {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.qr-logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.qr-logo .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.qr-logo .field > span { font-weight: 600; color: var(--text); }
.qr-logo .field b { color: var(--primary); }
.qr-logo-hint { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.qr-logo-hint-warn { color: #b45309; font-weight: 600; }

.password-output { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.password-output .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.password-output .field > span { font-weight: 600; color: var(--text); }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input {
  flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; font-family: "Consolas", "Courier New", monospace;
  background: var(--surface-2); color: var(--text); letter-spacing: 0.02em;
}
.copy-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.copy-row .btn { white-space: nowrap; }
.strength { display: flex; flex-direction: column; gap: 8px; }
.strength-bar {
  height: 8px; border-radius: 999px; background: var(--border); overflow: hidden;
}
.strength-bar span {
  display: block; height: 100%; width: 0%; border-radius: 999px;
  background: var(--danger); transition: width 0.25s ease, background 0.25s ease;
}
.strength-bar span.medium { background: #d97706; }
.strength-bar span.strong { background: #16a34a; }
.strength-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }

.wordcount-stats {
  margin-top: 2px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.imageconvert-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.imageconvert-preview-box { min-height: 240px; align-items: center; }
.imageconvert-preview-img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  display: block;
}
.imageconvert-caption { font-size: 12px; color: var(--text-faint); font-weight: 600; text-align: center; }
.imageconvert-result {
  display: flex; flex-direction: column; gap: 16px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.imageconvert-result .btn { align-self: flex-start; }

@media (max-width: 820px) {
  .utility-card.split,
  .imageconvert-grid { grid-template-columns: minmax(0, 1fr); }
  .qr-preview { min-height: 220px; }
}

/* ============ Shared previews ============ */
.preview-block { display: flex; flex-direction: column; gap: 8px; }
.preview-title { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.preview-box {
  background: var(--stage);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  justify-content: center;
  min-height: 140px;
}
.preview-wrap { position: relative; display: inline-block; line-height: 0; }
.preview-wrap canvas { max-width: 100%; max-height: 420px; box-shadow: var(--shadow-md); }
.preview-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.preview-text { position: absolute; transform-origin: center center; white-space: nowrap; font-weight: 700; }
.preview-image { position: absolute; transform-origin: center center; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.check-row input { accent-color: var(--primary); width: 16px; height: 16px; }

.tool-controls .field b { color: var(--primary); font-weight: 700; }
.tool-controls input[type="text"] {
  padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface); color: var(--text); width: 200px;
}
.tool-controls input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.tool-controls input[type="color"] {
  width: 46px; height: 38px; padding: 3px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.tool-workspace .check-row { align-self: flex-start; }

/* ============ Signature pad ============ */
.sign-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 800px) { .sign-grid { grid-template-columns: 1fr; } }
.sign-pad-wrap { display: flex; flex-direction: column; gap: 10px; }
.sign-pad-title, .sign-upload-title { font-size: 13px; font-weight: 700; color: var(--text-muted); }
#sign-canvas {
  width: 100%; height: auto; aspect-ratio: 640 / 240;
  background: #fff; border: 1px solid var(--border-strong); border-radius: 10px;
  touch-action: none; cursor: crosshair; box-shadow: var(--shadow-sm);
}
.sign-pad-actions { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.sign-width-field { flex: 1; min-width: 140px; }
.sign-width-field input[type="range"] { width: 100%; accent-color: var(--primary); }
.sign-pad-actions input[type="color"] {
  width: 44px; height: 38px; padding: 3px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
.sign-upload { display: flex; flex-direction: column; gap: 10px; }
.sign-upload-name { font-size: 12.5px; color: var(--text-muted); word-break: break-all; }

/* ============ Images to PDF ============ */
.img-thumb {
  width: 48px; height: 48px; flex-shrink: 0;
  object-fit: cover; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface-2);
}

/* ============ Metadata, blank pages, text extract ============ */
.inline-fields { display: flex; gap: 8px; }
.inline-fields input { width: 108px; }
#metadata-workspace .tool-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: end;
}
#metadata-workspace .tool-controls input[type="text"] { width: 100%; box-sizing: border-box; }
@media (max-width: 640px) {
  #metadata-workspace .tool-controls { grid-template-columns: 1fr; }
}
.meta-dates { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 4px; }
.tool-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.blank-result {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.65;
}
.blank-result b { color: var(--text); }
.blank-result .warn { color: var(--danger); font-weight: 700; }
.text-preview {
  max-height: 260px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ============ Watermark Remover ============ */
.wm-preview-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  touch-action: none;
}
.wm-preview-wrap canvas {
  max-width: 100%;
  max-height: 420px;
  box-shadow: var(--shadow-md);
}
.wm-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px dashed var(--primary);
  background: rgba(255, 255, 255, 0.45);
  cursor: move;
  touch-action: none;
}
.wm-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  touch-action: none;
}
.wm-handle[data-h="nw"] { left: -8px; top: -8px; cursor: nwse-resize; }
.wm-handle[data-h="ne"] { right: -8px; top: -8px; cursor: nesw-resize; }
.wm-handle[data-h="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.wm-handle[data-h="se"] { right: -8px; bottom: -8px; cursor: nwse-resize; }
.wm-fields { display: flex; gap: 16px; flex-wrap: wrap; }
.wm-fields .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.wm-fields .field span { font-weight: 600; color: var(--text); }
.wm-fields .field input {
  width: 100px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.wm-fields .field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

/* ============ Stage Tools (Redact / Form Builder) ============ */
.stage-workspace {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stage-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.stage-toolbar select,
.stage-toolbar input[type="text"] {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.stage-toolbar select:focus,
.stage-toolbar input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.stage-toolbar input[type="text"] { width: 150px; }
.stage-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}
.stage-hint { font-size: 12.5px; color: var(--text-faint); }
.stage-scroll {
  padding: 24px;
  background: var(--stage);
  overflow: auto;
  max-height: 68vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.stage-paper {
  position: relative;
  flex: 0 0 auto;
  max-width: 100%;
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.stage-paper canvas { display: block; width: 100%; height: auto; }
.draw-layer {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.redact-box,
.redact-temp {
  position: absolute;
  box-sizing: border-box;
  background: rgba(17, 24, 39, 0.9);
  border: 2px solid #ef4444;
  cursor: pointer;
}
.redact-temp { border-style: dashed; pointer-events: none; }
.redact-box::after {
  content: "×";
  position: absolute;
  top: -11px;
  right: -11px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.redact-box:hover { background: rgba(220, 38, 38, 0.92); }
.sigextract-box,
.sigextract-temp {
  position: absolute;
  box-sizing: border-box;
  background: rgba(37, 99, 235, 0.16);
  border: 2px solid var(--primary);
  cursor: pointer;
}
.sigextract-temp { border-style: dashed; pointer-events: none; }
.sigextract-box::after {
  content: "×";
  position: absolute;
  top: -11px;
  right: -11px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.sigextract-box:hover { background: rgba(37, 99, 235, 0.28); }
.sigextract-exclude,
.sigextract-exclude-temp {
  position: absolute;
  box-sizing: border-box;
  background: rgba(239, 68, 68, 0.18);
  border: 2px solid #ef4444;
  cursor: pointer;
}
.sigextract-exclude-temp { border-style: dashed; pointer-events: none; }
.sigextract-exclude::after {
  content: "×";
  position: absolute;
  top: -11px;
  right: -11px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.sigextract-exclude:hover { background: rgba(239, 68, 68, 0.3); }
.draw-layer.exclude-mode { cursor: cell; }
#sigextract-mark.active { background: var(--danger); border-color: var(--danger); color: #fff; }
#sigextract-mark.active:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.sigextract-result {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--surface);
}
.sigextract-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sigextract-preview-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  /* checkerboard to show transparency (neutral gray) */
  background-image:
    linear-gradient(45deg, #d4d4d4 25%, transparent 25%),
    linear-gradient(-45deg, #d4d4d4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d4d4d4 75%),
    linear-gradient(-45deg, transparent 75%, #d4d4d4 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #fff;
}
.sigextract-preview-box img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  image-rendering: auto;
}
.sigextract-preview-box #sigextract-preview-empty {
  color: var(--text-faint);
  font-size: 13px;
}
.sigextract-result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.stage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}
.stage-warn { color: var(--text-faint); }

/* Form builder */
.fb-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--primary);
  border-radius: 2px;
  background: rgba(37, 99, 235, 0.1);
  cursor: pointer;
  overflow: visible;
}
.fb-box.selected {
  background: rgba(37, 99, 235, 0.22);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}
.fb-box-label {
  position: absolute;
  left: -2px;
  top: -17px;
  max-width: 180px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.fb-box[data-kind="checkbox"] { background: rgba(16, 185, 129, 0.14); border-color: #10b981; }
.fb-box[data-kind="checkbox"] .fb-box-label { background: #10b981; }
.fb-box[data-kind="dropdown"] { background: rgba(245, 158, 11, 0.14); border-color: #d97706; }
.fb-box[data-kind="dropdown"] .fb-box-label { background: #d97706; }
.fb-temp {
  position: absolute;
  box-sizing: border-box;
  border: 2px dashed var(--primary);
  background: rgba(37, 99, 235, 0.12);
  pointer-events: none;
}
.formbuild-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.formbuild-list:empty { display: none; }
.formbuild-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.formbuild-row.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
.formbuild-row.no-options { grid-template-columns: minmax(0, 1fr) auto; }
.formbuild-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.formbuild-type { font-size: 11px; color: var(--text-faint); font-weight: 600; }
.formbuild-row input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.formbuild-row input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.formbuild-del {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.formbuild-del:hover { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .stage-scroll { padding: 12px; max-height: 60vh; }
  .stage-toolbar { gap: 6px; }
  .stage-hint { display: none; }
  .formbuild-row { grid-template-columns: minmax(0, 1fr) auto; }
  .formbuild-row .formbuild-options { grid-column: 1 / -1; }
}

/* ============ Footer ============ */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 24px;
  text-align: center;
}
.app-footer p { font-size: 12.5px; color: var(--text-faint); }
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin-top: 8px;
}
.footer-nav a {
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
}
.footer-nav a:hover { color: var(--primary); text-decoration: underline; }

/* ============ Ad slots ============ */
.ad-slot {
  max-width: 970px;
  margin: 32px auto 0;
  text-align: center;
}
.ad-label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ad-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-faint);
  font-size: 12.5px;
  overflow: hidden;
}
.ad-box:empty::before { content: "Ruang iklan"; }
.ad-slot-rectangle { max-width: 336px; margin-top: 36px; }
.ad-slot-rectangle .ad-box { min-height: 280px; }

/* Banner sponsor (Direct Link Adsterra) yang mengisi ad-box */
.ad-box a.ad-link {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  min-height: inherit;
  padding: 18px 22px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1d4ed8, #2563eb 55%, #3b82f6);
  color: #fff;
  text-decoration: none;
  text-align: left;
  transition: filter 0.15s, transform 0.15s;
}
.ad-box a.ad-link:hover { filter: brightness(1.06); transform: translateY(-1px); }
.ad-link-tag {
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.ad-link-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ad-link-body b { font-size: 15px; letter-spacing: -0.01em; }
.ad-link-body small { font-size: 12px; color: rgba(255, 255, 255, 0.82); }
.ad-link svg { width: 20px; height: 20px; margin-left: auto; flex-shrink: 0; opacity: 0.9; }
.ad-link-tall { flex-direction: column; text-align: center; justify-content: center; gap: 12px; }
.ad-link-tall svg { margin-left: 0; }
@media (max-width: 640px) {
  .ad-box a.ad-link { padding: 14px 16px; gap: 10px; }
  .ad-link-body b { font-size: 13.5px; }
  .ad-link-body small { font-size: 11px; }
}
@media (min-width: 768px) {
  .ad-slot-leaderboard .ad-box { min-height: 90px; }
}
@media (max-width: 640px) {
  .ad-slot { margin-top: 28px; }
  .ad-slot-rectangle { margin-top: 30px; }
}

/* ============ Legal / privacy ============ */
.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 56px;
  text-align: left;
}
.legal-brand { color: inherit; text-decoration: none; }
.legal-back { margin-bottom: 18px; font-size: 13px; }
.legal-back a { color: var(--primary); text-decoration: none; }
.legal-back a:hover { text-decoration: underline; }
.legal-page h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.legal-updated { margin-top: 6px; font-size: 12.5px; color: var(--text-faint); }
.legal-page h2 {
  margin: 28px 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.legal-page p,
.legal-page li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
}
.legal-page ul { margin: 8px 0 0 20px; }
.legal-page a { color: var(--primary); }
@media (min-width: 960px) {
  body.legal-body { display: block; background: var(--bg); }
}

/* ============ SEO content ============ */
.seo-section {
  max-width: 900px;
  margin: 48px auto 0;
  padding-top: 36px;
  border-top: 1px solid var(--border);
  text-align: left;
  scroll-margin-top: 140px;
}
.seo-section h2 {
  margin-bottom: 12px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.seo-intro p {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
}
.seo-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 18px;
  list-style: none;
}
.seo-points li {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}
.seo-points strong { color: var(--text); }
.seo-tools { margin-top: 36px; scroll-margin-top: 140px; }
.seo-tool-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 22px;
}
.seo-tool-group h3 {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.seo-tool-group ul {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
}
.seo-tool-group a {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  text-decoration: none;
}
.seo-tool-group a:hover { color: var(--primary); text-decoration: underline; }
.seo-faq { margin-top: 36px; scroll-margin-top: 140px; }
.seo-faq-item {
  margin-bottom: 8px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.seo-faq-item summary {
  position: relative;
  padding: 12px 24px 12px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.seo-faq-item summary::-webkit-details-marker { display: none; }
.seo-faq-item summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-faint);
}
.seo-faq-item[open] summary::after { content: "−"; }
.seo-faq-item p {
  padding: 0 0 14px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-muted);
}
@media (max-width: 640px) {
  .seo-section { margin-top: 36px; padding-top: 28px; }
  .seo-section h2 { font-size: 19px; }
  .seo-tool-groups { gap: 18px 20px; }
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-width: 90vw;
  animation: fadeIn 0.15s ease;
}
.toast.error { background: var(--danger); }

/* ============ Loading ============ */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
}
.loading-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}
.loading-card p { color: var(--text-muted); font-size: 14px; font-weight: 600; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Scrollbars ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ Responsive ============ */
@media (max-width: 560px) {
  .header-inner, .tabs-inner { padding-left: 16px; padding-right: 16px; }
  main { padding: 20px 16px 32px; }
  .nav-cat { padding: 8px 11px; font-size: 12.5px; }
  .nav-cat svg { display: none; }
  .page-head { gap: 12px; margin-bottom: 16px; }
  .page-head-icon { width: 40px; height: 40px; border-radius: 10px; }
  .page-head-icon svg { width: 20px; height: 20px; }
  .page-title { font-size: 17px; }
  .page-desc { font-size: 13px; }
  .tab { padding: 12px 12px; font-size: 13px; }
  .tab svg { display: none; }
  .list-header { flex-direction: column; align-items: flex-start; }
  .editor { height: calc(100vh - 210px); }
  .pages-sidebar { width: 112px; }
  .editor-stage { padding: 16px; }
  .item { flex-wrap: wrap; }
  .item-range { width: 100%; }
  .item-range input { width: 100%; }
}

/* ============ Desktop app shell ============ */
@media (min-width: 960px) {
  body.app-body {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    background:
      linear-gradient(var(--border), var(--border)) 271px 0 / 1px 100% no-repeat,
      linear-gradient(var(--surface), var(--surface)) 0 0 / 272px 100% no-repeat,
      var(--bg);
  }
  .app-header { grid-column: 1 / -1; }
  .header-inner { max-width: none; padding: 18px 28px; }

  .tabs {
    grid-column: 1;
    grid-row: 2;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    padding: 18px 16px 24px;
    scrollbar-width: thin;
  }
  .tabs-inner { max-width: none; margin: 0; padding: 0; }
  .nav-sidebar-head {
    display: block;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    padding: 0 4px 14px;
  }
  .nav-primary {
    flex-direction: column;
    gap: 2px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }
  .nav-sub {
    flex-direction: column;
    gap: 0;
    padding: 14px 0 0;
    overflow: visible;
  }
  .nav-sub-group { flex-direction: column; gap: 2px; }

  .nav-cat {
    width: 100%;
    justify-content: flex-start;
    gap: 9px;
    padding: 8px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 13px;
    color: var(--text-muted);
  }
  .nav-cat:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
  .nav-cat.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
  .nav-cat::after {
    content: "";
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    opacity: 0.5;
    transition: transform 0.15s;
  }
  .nav-cat.active::after { transform: rotate(-135deg); opacity: 0.8; }
  .nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-faint);
    font-size: 10.5px;
    font-weight: 700;
  }
  .nav-cat.active .nav-count { background: rgba(37, 99, 235, 0.12); color: var(--primary); }

  .nav-sub .tab {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    padding: 7px 9px 7px 31px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 12.8px;
    color: var(--text-muted);
  }
  .nav-sub .tab:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
  .nav-sub .tab.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
  .nav-sub .tab svg { flex-shrink: 0; }
  .nav-empty { padding: 4px 9px 0; }

  body.app-body main {
    grid-column: 2;
    grid-row: 2;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 32px 48px;
  }
  body.app-body .app-footer { grid-column: 1 / -1; grid-row: 3; }
}
