/* Round 97r - Crop & Resize PDF (templates/tools/crop_pdf.html, static/js/crop_pdf.js) */
.cp-app { margin-top: 18px; }
.cp-app .btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.cp-filebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.cp-filename { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }

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

/* page strip */
.cp-thumbs { display: flex; flex-direction: column; gap: 12px; max-height: 78vh; overflow: auto; padding: 4px 6px 4px 2px; }
.cp-thumb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 10px;
  border: 2px solid transparent; background: var(--card); cursor: pointer; font: inherit; color: inherit; }
.cp-thumb:hover { border-color: var(--border); }
.cp-thumb.is-on { border-color: var(--primary, var(--accent)); box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.cp-tframe { position: relative; overflow: hidden; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); line-height: 0; }
.cp-tframe canvas { display: block; transform-origin: 50% 50%; }
.cp-tbox { position: absolute; box-shadow: 0 0 0 999px rgba(15, 23, 42, .42); outline: 1.5px solid #fff; pointer-events: none; }
.cp-tlabel { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.cp-tlabel .cp-tag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--tint); color: var(--text); font-weight: 700; }

/* editor */
.cp-editor { min-width: 0; }
.cp-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; }
.cp-pageno { font-weight: 700; min-width: 120px; text-align: center; }
.cp-stage { display: flex; justify-content: center; align-items: center; padding: 16px; border-radius: 14px; background: repeating-conic-gradient(#eef0f4 0 25%, #f7f8fa 0 50%) 0 0 / 22px 22px;
  border: 1px solid var(--border); min-height: 260px; }
.cp-wrap { position: relative; line-height: 0; overflow: visible; background: #fff; box-shadow: 0 6px 22px rgba(0, 0, 0, .18); touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.cp-wrap canvas { display: block; transform-origin: 50% 50%; }
/* canvas + dark shade are clipped to the page; the box and its handles are not (handles sit on the edge) */
.cp-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cp-shade { position: absolute; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .5); }
.cp-cropbox { position: absolute; background-color: transparent; outline: 2px solid #fff; cursor: move; touch-action: none;
  background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px);
  background-size: 33.333% 33.333%; background-position: -1px -1px; }
.cp-h { position: absolute; width: 18px; height: 18px; background: #fff; border: 2px solid var(--primary, #2E5395); border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .35); touch-action: none; z-index: 2; }
.cp-h::after { content: ""; position: absolute; inset: -12px; }             /* bigger touch target */
.cp-h-n, .cp-h-s { left: 50%; margin-left: -9px; width: 34px; margin-left: -17px; height: 12px; border-radius: 8px; cursor: ns-resize; }
.cp-h-e, .cp-h-w { top: 50%; margin-top: -17px; width: 12px; height: 34px; border-radius: 8px; cursor: ew-resize; }
.cp-h-n { top: -7px; } .cp-h-s { bottom: -7px; } .cp-h-w { left: -7px; } .cp-h-e { right: -7px; }
.cp-h-nw { left: -9px; top: -9px; cursor: nwse-resize; } .cp-h-se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.cp-h-ne { right: -9px; top: -9px; cursor: nesw-resize; } .cp-h-sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.cp-dims { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); padding: 3px 8px; border-radius: 6px; background: rgba(15, 23, 42, .78);
  color: #fff; font: 600 12px/1.4 system-ui, sans-serif; white-space: nowrap; pointer-events: none; }
.cp-hint { text-align: center; margin: 8px 0 14px; }

.cp-group { padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); margin-bottom: 12px; }
.cp-gh { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 10px; }
.cp-mm { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.cp-mm label, .cp-custom label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 700; }
.cp-mm input, .cp-custom input { width: 100%; }
.cp-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.cp-angle { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-weight: 700; font-size: 13px; }
.cp-angle input[type=range] { flex: 1 1 160px; }
.cp-angle input[type=number] { width: 76px; }
.cp-copied { margin: 8px 0 0; min-height: 1em; color: var(--accent); font-weight: 600; }

/* side panel */
.cp-side { position: sticky; top: calc(var(--lbp-header-h, 64px) + 12px); }
.cp-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.cp-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.cp-summary { margin: 4px 0 0; }
.cp-dl { width: 100%; justify-content: center; }
.cp-progress { margin-top: 10px; text-align: center; font-weight: 600; }

@media (max-width: 1100px) {
  .cp-layout { grid-template-columns: 130px minmax(0, 1fr); }
  .cp-side { grid-column: 1 / -1; position: static; }
}
@media (max-width: 720px) {
  .cp-layout { grid-template-columns: minmax(0, 1fr); }
  .cp-thumbs { flex-direction: row; max-height: none; overflow-x: auto; padding-bottom: 8px; }
  .cp-thumb { flex: none; }
  .cp-mm { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-stage { padding: 10px; }
}
.cp-app input[type=number] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card-solid, var(--card)); color: var(--text); font: inherit; font-size: 14px; line-height: 1.3; }
.cp-app input[type=number]:focus { outline: 2px solid var(--primary, #2E5395); outline-offset: 1px; }
.cp-angle input[type=range] { accent-color: var(--primary, #2E5395); }
