/* Crop PDF Pages & Trim Margins (/tools/crop-pdf-margins/), 2026-11-30.
   Uses tokens from ft-shell-20261106.css and components from ft-tool-20261106.css.
   Reserves preview stage and check-card heights from first paint so CLS stays 0.000. */

.ft-tool .ft-fields {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), minmax(0, 1fr)));
}

.ft-tool .ft-field,
.ft-tool fieldset,
.ft-tool .ft-panel,
.ft-tool .ft-stack,
.ft-tool .ft-inputgroup {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.ft-tool .ft-select {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ft-tool input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.ft-tool select,
.ft-tool textarea,
.ft-tool .ft-input,
.ft-tool .ft-select {
  font-size: max(16px, 1rem);
  min-height: 44px;
}

.ft-tool .ft-btn {
  min-width: 44px;
  min-height: 44px;
  height: auto;
  padding-block: 0.48rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.cpdf-filebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ft-space-2) var(--ft-space-3);
  margin-top: calc(-1 * var(--ft-space-2));
}

.cpdf-fileinfo {
  flex: 1 1 13rem;
  min-width: 0;
  margin: 0;
  color: var(--ft-ink-2);
  font-size: var(--ft-text-sm);
  overflow-wrap: anywhere;
}

.cpdf-fileinfo strong {
  color: var(--ft-ink);
  font-weight: 650;
}

.cpdf-presets {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ft-space-2);
}

.cpdf-presets__label {
  margin: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-sm);
  font-weight: 600;
}

.cpdf-presets__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ft-space-2);
}

.cpdf-preset {
  justify-content: flex-start;
  text-align: left;
}

.cpdf-preset[aria-pressed="true"] {
  border-color: var(--ft-accent);
  background: var(--ft-accent-soft);
  color: var(--ft-ink);
  font-weight: 650;
}

.cpdf-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ft-space-3);
  min-width: 0;
  margin: 0;
  padding: var(--ft-space-4) 0 0;
  border: 0;
  border-top: 1px solid var(--ft-line);
}

.cpdf-group__legend {
  float: left;
  width: 100%;
  margin: 0 0 var(--ft-space-1);
  padding: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-md);
  font-weight: 650;
}

.cpdf-group__legend + * {
  clear: both;
}

.cpdf-margin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ft-space-2);
}

.cpdf-unitwrap {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface);
  overflow: hidden;
}

.cpdf-unitwrap:focus-within {
  outline: 2px solid var(--ft-accent);
  outline-offset: 1px;
}

.cpdf-unitwrap .ft-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  padding-inline: 0.6rem;
}

.cpdf-unitbadge {
  display: inline-flex;
  align-items: center;
  padding-inline: 0.5rem;
  border-left: 1px solid var(--ft-line);
  background: var(--ft-surface-2, var(--ft-surface));
  color: var(--ft-ink-2);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.cpdf-even-panel {
  display: grid;
  gap: var(--ft-space-2);
  padding: var(--ft-space-3);
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2, var(--ft-surface));
}

.cpdf-even-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ft-space-2);
}

.cpdf-even-title {
  margin: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-sm);
  font-weight: 650;
}

.cpdf-check {
  display: flex;
  align-items: center;
  gap: var(--ft-space-2);
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface);
  color: var(--ft-ink);
  line-height: 1.35;
  box-sizing: border-box;
}

.cpdf-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
}

.cpdf-check span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cpdf-scope-note {
  margin: 0;
  color: var(--ft-ink-2);
  font-size: var(--ft-text-sm);
  line-height: 1.45;
}

.cpdf-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ft-space-2);
}

.cpdf-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.cpdf-pill {
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface);
  color: var(--ft-ink-2);
  font: inherit;
  font-size: max(16px, var(--ft-text-sm));
  cursor: pointer;
}

.cpdf-pill[aria-pressed="true"] {
  border-color: var(--ft-accent);
  background: var(--ft-accent-soft);
  color: var(--ft-ink);
  font-weight: 650;
}

.cpdf-preview {
  margin: 0;
}

.cpdf-frame {
  position: relative;
  display: grid;
  place-items: center;
  height: 31.5rem;
  max-width: 100%;
  padding: var(--ft-space-3);
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2, var(--ft-surface));
  overflow: hidden;
  box-sizing: border-box;
}

.cpdf-stage {
  position: relative;
  width: 320px;
  height: 414px;
  max-width: 100%;
  max-height: 100%;
  border-radius: 3px;
  box-shadow: 0 6px 22px rgba(15, 23, 32, 0.14);
  background: #ffffff;
  user-select: none;
}

.cpdf-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 3px;
  background: #ffffff;
}

.cpdf-overlay {
  position: absolute;
  inset: 0;
  touch-action: none;
}

.cpdf-mask {
  position: absolute;
  background: rgba(15, 26, 22, 0.44);
  pointer-events: none;
}

.cpdf-mask--top {
  top: 0;
  left: 0;
  right: 0;
  height: 0;
}

.cpdf-mask--bottom {
  bottom: 0;
  left: 0;
  right: 0;
  height: 45.45%;
}

.cpdf-mask--left {
  left: 0;
  top: 0;
  bottom: 45.45%;
  width: 0;
}

.cpdf-mask--right {
  right: 0;
  top: 0;
  bottom: 45.45%;
  width: 52.94%;
}

.cpdf-box {
  position: absolute;
  left: 0;
  top: 0;
  width: 47.06%;
  height: 54.55%;
  border: 2px solid #167956;
  box-sizing: border-box;
  cursor: move;
}

.cpdf-box__tag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  max-width: calc(100% - 8px);
  padding: 0.14rem 0.42rem;
  border-radius: 4px;
  background: rgba(16, 48, 37, 0.88);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.cpdf-handle {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid #ffffff;
  border-radius: 3px;
  background: #167956;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}

.cpdf-handle--nw { top: -6px; left: -6px; cursor: nwse-resize; }
.cpdf-handle--n  { top: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.cpdf-handle--ne { top: -6px; right: -6px; cursor: nesw-resize; }
.cpdf-handle--e  { top: calc(50% - 6px); right: -6px; cursor: ew-resize; }
.cpdf-handle--se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.cpdf-handle--s  { bottom: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.cpdf-handle--sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.cpdf-handle--w  { top: calc(50% - 6px); left: -6px; cursor: ew-resize; }

.cpdf-busy {
  position: absolute;
  inset: auto var(--ft-space-3) var(--ft-space-3);
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-radius: var(--ft-radius);
  background: var(--ft-surface);
  border: 1px solid var(--ft-line);
  color: var(--ft-ink);
  font-size: var(--ft-text-sm);
  font-weight: 600;
  text-align: center;
}

.cpdf-checkcard {
  display: grid;
  gap: var(--ft-space-3);
  padding: var(--ft-space-3);
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface);
}

.cpdf-checkcard__head {
  display: grid;
  gap: 0.25rem;
}

.cpdf-checkcard__title {
  margin: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-md);
  font-weight: 650;
}

.cpdf-checkcard__sub {
  margin: 0;
  color: var(--ft-ink-2);
  font-size: var(--ft-text-sm);
}

.cpdf-stats {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), minmax(0, 1fr)));
}

.cpdf-after-example {
  margin-top: var(--ft-space-3);
}

.ft-status {
  min-height: 1.35rem;
}

@media (max-width: 520px) {
  .cpdf-frame {
    height: 22rem;
    padding: var(--ft-space-2);
  }

  .cpdf-margin-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
