/*
 * The PDF tools pages (/pdf-tools, /pdf-tools/{id}). Loaded after site.css
 * and built on its colour tokens (--c-*), so light/dark - the system's or the
 * visitor's choice - comes for free. Hand-written, not Tailwind: it ships as
 * it is, no build. Every class is `pt-` so nothing here can restyle another
 * page.
 */

.pt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- hero -- */

.pt-hero {
  border-bottom: 1px solid var(--c-line);
  background: linear-gradient(135deg, var(--c-brand-soft), var(--c-canvas) 60%);
  padding: 2.5rem 0 2rem;
}

.pt-hero--tool { padding-bottom: 1.75rem; }

.pt-crumbs { font-size: 0.875rem; color: var(--c-faint); }
.pt-crumbs a { color: var(--c-faint); }
.pt-crumbs a:hover { color: var(--c-ink); }

.pt-hero__title {
  margin-top: 0.75rem;
  font-size: clamp(1.75rem, 4.5vw, 2.6rem);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--c-ink);
}

.pt-hero__lead {
  margin-top: 0.75rem;
  max-width: 44rem;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--c-muted);
}

.pt-tool-head { display: flex; gap: 1rem; align-items: flex-start; margin-top: 0.5rem; }
.pt-tool-head .pt-hero__title { margin-top: 0; }

.pt-tool-meta { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.pt-tool-meta__text { font-size: 0.8125rem; color: var(--c-faint); }

/* -------------------------------------------------------------- search -- */

.pt-search { position: relative; margin-top: 1.5rem; max-width: 34rem; }

.pt-search__icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-faint);
  pointer-events: none;
}

.pt-search__input {
  width: 100%;
  border: 1px solid var(--c-line);
  border-radius: 0.875rem;
  background: var(--c-surface);
  color: var(--c-ink);
  padding: 0.8rem 1rem 0.8rem 2.6rem;
  font-size: 1rem;
  box-shadow: 0 10px 30px -22px rgb(15 23 42 / 0.6);
}

.pt-search__input:focus { outline: 2px solid var(--c-brand); outline-offset: 1px; }

.pt-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }

.pt-pill {
  border-radius: 9999px;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  padding: 0.4rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--c-muted);
}

.pt-pill:hover { color: var(--c-ink); border-color: var(--c-brand); }

.pt-pill.is-active {
  background-image: linear-gradient(135deg, var(--c-brand), var(--c-brand-2));
  border-color: transparent;
  color: #fff;
}

/* --------------------------------------------------------------- cards -- */

.pt-groups { padding-top: 2rem; padding-bottom: 1rem; }
.pt-group { margin-bottom: 2.25rem; scroll-margin-top: 5rem; }
.pt-group__title { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.01em; color: var(--c-ink); }

.pt-cards {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) { .pt-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .pt-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.pt-card {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.pt-card:hover {
  transform: translateY(-2px);
  border-color: var(--c-brand);
  box-shadow: 0 14px 30px -20px rgb(15 23 42 / 0.55);
}

.pt-card__icon {
  --pt-tint: #2563eb;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 0.75rem;
  color: #fff;
  background: var(--pt-tint);
}

.pt-card__icon--lg { width: 3.5rem; height: 3.5rem; border-radius: 1rem; }
.pt-card__icon--sm { width: 1.75rem; height: 1.75rem; border-radius: 0.5rem; }

.pt-cat-organize { --pt-tint: #2f5fd0; }
.pt-cat-optimize { --pt-tint: #0f766e; }
.pt-cat-convert-to { --pt-tint: #b45309; }
.pt-cat-convert-from { --pt-tint: #7c3aed; }
.pt-cat-edit { --pt-tint: #be1f63; }
.pt-cat-security { --pt-tint: #15803d; }

.pt-card__body { min-width: 0; flex: 1; }
.pt-card__head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.pt-card__title { font-weight: 650; color: var(--c-ink); }
.pt-card__text { display: block; margin-top: 0.2rem; font-size: 0.875rem; line-height: 1.45; color: var(--c-muted); }

.pt-badge {
  display: inline-block;
  border-radius: 9999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--c-sunken);
  color: var(--c-muted);
}

.pt-badge--pro { background: rgb(245 158 11 / 0.16); color: #b45309; }
.pt-badge--free { background: rgb(16 185 129 / 0.14); color: #047857; }
.pt-badge--app { background: var(--c-brand-soft); color: var(--c-brand); }

.pt-empty { padding: 2rem 0; text-align: center; color: var(--c-muted); }

/* --------------------------------------------------------------- trust -- */

.pt-trust {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  padding-top: 1rem;
  padding-bottom: 2rem;
}

@media (min-width: 768px) { .pt-trust { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.pt-trust__item {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 1rem;
  background: var(--c-raised);
  color: var(--c-brand);
}

.pt-trust__item strong { color: var(--c-ink); }
.pt-trust__item p { margin-top: 0.2rem; font-size: 0.875rem; color: var(--c-muted); }

/* ---------------------------------------------------------- tool page -- */

.pt-layout {
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1fr);
  padding-top: 2rem;
  padding-bottom: 2rem;
}

@media (min-width: 1024px) { .pt-layout { grid-template-columns: minmax(0, 1fr) 17rem; } }

.pt-tool { padding: 1.25rem; }
@media (min-width: 640px) { .pt-tool { padding: 1.75rem; } }

.pt-account {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--c-muted);
  overflow-wrap: anywhere;
}

.pt-link {
  color: var(--c-brand);
  font-weight: 600;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pt-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.25rem 1rem;
  border: 2px dashed var(--c-line);
  border-radius: 1rem;
  background: var(--c-raised);
  text-align: center;
  color: var(--c-brand);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.pt-drop:hover, .pt-drop.is-over { border-color: var(--c-brand); background: var(--c-brand-soft); }
.pt-drop:focus-within { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.pt-drop--locked { cursor: default; }
.pt-drop--locked:hover { border-color: var(--c-line); background: var(--c-raised); }

.pt-drop__title { font-size: 1.0625rem; font-weight: 700; color: var(--c-ink); }
.pt-drop__hint { font-size: 0.875rem; color: var(--c-muted); max-width: 30rem; }
.pt-drop .btn { margin-top: 0.5rem; }

/* "Continue with Google": Google's light button (white, grey outline, the
   four-colour G). The same in dark mode - Google's guidelines allow it, and
   it reads as the familiar button on any background. */
.pt-google-wrap { display: grid; justify-items: center; gap: 0.75rem; margin-top: 0.5rem; width: 100%; max-width: 20rem; }
.pt-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border: 1px solid #747775;
  border-radius: 999px;
  background: #fff;
  color: #1f1f1f;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.pt-google:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3); }
.pt-google:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.pt-google__logo { flex: none; }
.pt-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  font-size: 0.8125rem;
  color: var(--c-muted);
}
.pt-or::before, .pt-or::after { content: ''; flex: 1; height: 1px; background: var(--c-line); }
.pt-google-wrap + .btn { margin-top: 0; }

/* The real input covers the box, so a tap anywhere opens the picker and the
   keyboard reaches it; it is transparent rather than hidden. */
.pt-drop__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.pt-form { margin-top: 1.25rem; display: grid; gap: 0.9rem; max-width: 26rem; }
.pt-form__lead { color: var(--c-muted); font-size: 0.9375rem; overflow-wrap: anywhere; }
.pt-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.pt-field { display: grid; gap: 0.35rem; }
.pt-field__label { font-size: 0.875rem; font-weight: 600; color: var(--c-ink); }
.pt-field__hint { font-size: 0.8125rem; color: var(--c-faint); }
.pt-req { color: var(--c-danger); }

.pt-input {
  width: 100%;
  border: 1px solid var(--c-line);
  border-radius: 0.65rem;
  background: var(--c-surface);
  color: var(--c-ink);
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
}

.pt-input:focus { outline: 2px solid var(--c-brand); outline-offset: 1px; }
.pt-input--code { letter-spacing: 0.25em; font-variant-numeric: tabular-nums; max-width: 14rem; }

.pt-toggle { display: inline-flex; align-items: center; gap: 0.55rem; font-size: 0.9375rem; color: var(--c-ink); cursor: pointer; }
.pt-toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--c-brand); }

.pt-files { margin-top: 1rem; display: grid; gap: 0.5rem; }
.pt-files:empty { display: none; }

.pt-file {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--c-line);
  border-radius: 0.75rem;
  background: var(--c-surface);
  font-size: 0.875rem;
}

.pt-file__num { flex: none; width: 1.5rem; text-align: center; font-weight: 700; color: var(--c-faint); }
.pt-file__name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-ink); }
.pt-file__size { flex: none; color: var(--c-faint); }

.pt-file__btn {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: 1px solid var(--c-line);
  background: var(--c-raised);
  color: var(--c-muted);
  cursor: pointer;
  line-height: 1;
}

.pt-file__btn:hover:not(:disabled) { color: var(--c-ink); border-color: var(--c-brand); }
.pt-file__btn:disabled { opacity: 0.4; cursor: default; }

.pt-note {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.75rem;
  background: var(--c-brand-soft);
  color: var(--c-ink);
  font-size: 0.875rem;
}

.pt-options {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--c-line);
  border-radius: 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) { .pt-options { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.pt-options__title { padding: 0 0.35rem; font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-faint); }
.pt-field--toggle { align-self: center; }

.pt-error {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.75rem;
  background: rgb(225 29 72 / 0.1);
  color: var(--c-danger);
  font-size: 0.9375rem;
  font-weight: 550;
}

.pt-progress { margin-top: 1.1rem; display: grid; gap: 0.4rem; font-size: 0.875rem; color: var(--c-muted); }

.pt-progress progress {
  width: 100%;
  height: 0.6rem;
  border: 0;
  border-radius: 9999px;
  overflow: hidden;
  background: var(--c-sunken);
  accent-color: var(--c-brand);
}

.pt-progress progress::-webkit-progress-bar { background: var(--c-sunken); border-radius: 9999px; }
.pt-progress progress::-webkit-progress-value { background: linear-gradient(90deg, var(--c-brand), var(--c-brand-2)); border-radius: 9999px; }
.pt-progress progress::-moz-progress-bar { background: linear-gradient(90deg, var(--c-brand), var(--c-brand-2)); border-radius: 9999px; }

.pt-run { margin-top: 1.25rem; width: 100%; }
@media (min-width: 640px) { .pt-run { width: auto; } }
.pt-run:disabled { opacity: 0.6; cursor: progress; transform: none; }

.pt-upsell { display: grid; gap: 0.6rem; justify-items: start; }
.pt-upsell__title { font-size: 1.25rem; font-weight: 750; color: var(--c-ink); }
.pt-upsell__text { color: var(--c-muted); }

.pt-result { display: grid; gap: 1.1rem; }
.pt-result__head { display: flex; gap: 0.8rem; align-items: center; }

.pt-result__tick {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 9999px;
  background: rgb(16 185 129 / 0.15);
  color: var(--c-positive);
}

.pt-result__title { font-size: 1.2rem; font-weight: 750; color: var(--c-ink); }
.pt-result__file { font-size: 0.875rem; color: var(--c-muted); overflow-wrap: anywhere; }

/* ---------------------------------------------------- page sections -- */

.pt-section { margin-top: 2.5rem; }
.pt-section__title { font-size: 1.3rem; font-weight: 750; color: var(--c-ink); }

.pt-steps { margin-top: 0.9rem; display: grid; gap: 0.6rem; padding-left: 1.25rem; list-style: decimal; color: var(--c-muted); }
.pt-steps strong { color: var(--c-ink); }

.pt-faq { margin-top: 0.9rem; display: grid; gap: 0.6rem; }
.pt-faq__item { border: 1px solid var(--c-line); border-radius: 0.875rem; background: var(--c-surface); padding: 0.8rem 1rem; }
.pt-faq__item summary { cursor: pointer; font-weight: 650; color: var(--c-ink); }
.pt-faq__item p { margin-top: 0.5rem; color: var(--c-muted); line-height: 1.6; }

.pt-aside__title { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-faint); }
.pt-related { margin-top: 0.75rem; display: grid; gap: 0.4rem; }

.pt-related__link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.75rem;
  color: var(--c-ink);
  font-size: 0.9375rem;
  font-weight: 550;
}

.pt-related__link:hover { background: var(--c-raised); }
.pt-aside__all { display: inline-block; margin-top: 0.75rem; font-size: 0.875rem; text-decoration: none; }

/* --------------------------------------------------------- app prompt -- */

.pt-store {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 0.6rem;
  background: #000;
  color: #fff;
  padding: 0.45rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 650;
  white-space: nowrap;
}

.pt-store:hover { background: #1f2937; }
.pt-store--lg { padding: 0.65rem 1rem; font-size: 0.9375rem; }

.pt-promo {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.1rem;
  border-radius: 1rem;
  border: 1px solid var(--c-line);
  background: linear-gradient(135deg, var(--c-brand-soft), var(--c-surface));
}

.pt-promo--editor { padding: 1.5rem; }
.pt-promo__logo { flex: none; border-radius: 0.75rem; }
.pt-promo__title { font-weight: 750; color: var(--c-ink); }
.pt-promo__text { margin-top: 0.25rem; font-size: 0.9375rem; color: var(--c-muted); }
.pt-promo__actions { margin-top: 0.8rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }

.pt-appbar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin-top: 2rem;
  border-top: 1px solid var(--c-line);
  background: var(--c-surface);
  box-shadow: 0 -12px 30px -24px rgb(15 23 42 / 0.6);
}

.pt-appbar__inner { display: flex; align-items: center; gap: 0.75rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
.pt-appbar__logo { flex: none; border-radius: 0.5rem; }
.pt-appbar__text { min-width: 0; flex: 1; font-size: 0.875rem; line-height: 1.35; color: var(--c-muted); }
.pt-appbar__text strong { color: var(--c-ink); margin-right: 0.25rem; }
.pt-appbar__actions { flex: none; display: flex; align-items: center; gap: 0.4rem; }

.pt-appbar__close {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  border: 0;
  background: none;
  color: var(--c-faint);
  cursor: pointer;
}

.pt-appbar__close:hover { color: var(--c-ink); background: var(--c-raised); }

@media (max-width: 520px) {
  .pt-appbar__text span { display: none; }
  .pt-appbar [data-pt-store="ios"] { display: none; }
}

/* Dark mode: the soft badge colours need lighter ink. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .pt-badge--pro { color: #fbbf24; }
  :root:not([data-theme='light']) .pt-badge--free { color: #34d399; }
  :root:not([data-theme='light']) .pt-error { color: #fb7185; }
  :root:not([data-theme='light']) .pt-store { background: #0b0f1a; border: 1px solid var(--c-line); }
}

:root[data-theme='dark'] .pt-badge--pro { color: #fbbf24; }
:root[data-theme='dark'] .pt-badge--free { color: #34d399; }
:root[data-theme='dark'] .pt-error { color: #fb7185; }
:root[data-theme='dark'] .pt-store { background: #0b0f1a; border: 1px solid var(--c-line); }

@media (prefers-reduced-motion: reduce) {
  .pt-card, .pt-drop { transition: none; }
  .pt-card:hover { transform: none; }
}

/* ------------------------------------------------- visual crop editor -- */
/*
 * /pdf-tools/crop-pdf. The stage is sized by pdf-tools.js to the page's
 * shape; the box, the hole in the shade and the handles are positioned in
 * percent of it, so nothing depends on the preview's pixel size.
 */

.pt-crop { margin-top: 1rem; display: grid; gap: 0.75rem; }

.pt-crop__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.pt-crop__pager { display: inline-flex; align-items: center; gap: 0.25rem; }

.pt-crop__nav {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 0.65rem;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  color: var(--c-ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.pt-crop__nav:hover:not(:disabled) { border-color: var(--c-brand); color: var(--c-brand); }
.pt-crop__nav:disabled { opacity: 0.4; cursor: default; }
.pt-crop__nav:focus-visible, .pt-crop__reset:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }

.pt-crop__pageof {
  min-width: 6.5rem;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 650;
  color: var(--c-ink);
  font-variant-numeric: tabular-nums;
}

/* "All pages / This page only": a two-way segmented switch. */
.pt-seg {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 0.8rem;
  background: var(--c-sunken);
  border: 1px solid var(--c-line);
}

.pt-seg__opt { position: relative; cursor: pointer; }

.pt-seg__opt input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.pt-seg__opt span {
  display: block;
  min-height: 2.5rem;
  line-height: 2.5rem;
  padding: 0 0.85rem;
  border-radius: 0.6rem;
  font-size: 0.875rem;
  font-weight: 650;
  color: var(--c-muted);
  white-space: nowrap;
}

.pt-seg__opt input:checked + span {
  background: var(--c-surface);
  color: var(--c-ink);
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.18);
}

.pt-seg__opt input:focus-visible + span { outline: 2px solid var(--c-brand); outline-offset: 1px; }

.pt-crop__reset {
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 0.65rem;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  color: var(--c-ink);
  font-weight: 650;
  font-size: 0.875rem;
  cursor: pointer;
}

.pt-crop__reset:hover { border-color: var(--c-brand); color: var(--c-brand); }

.pt-crop__help { font-size: 0.875rem; color: var(--c-muted); }

/* Room around the page (the inset) so a handle on the page's edge is still
   a whole finger-sized target. */
.pt-crop__canvas {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  border-radius: 1rem;
  background: var(--c-sunken);
  border: 1px solid var(--c-line);
  overflow: hidden;
}

.pt-crop__stage {
  position: relative;
  flex: none;
  max-width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
}

.pt-crop__img {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  box-shadow: 0 10px 30px -18px rgb(15 23 42 / 0.6);
  pointer-events: none;
}

.pt-crop__img:not([src]) { visibility: hidden; }

.pt-crop__shade { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.pt-crop__hole {
  position: absolute;
  box-shadow: 0 0 0 200vmax rgb(15 23 42 / 0.55);
}

.pt-crop__box {
  position: absolute;
  border: 2px solid #fff;
  outline: 1px solid rgb(15 23 42 / 0.55);
  cursor: move;
  touch-action: none;
}

.pt-crop__box:focus { outline: 1px solid rgb(15 23 42 / 0.55); }
.pt-crop__box:focus-visible { box-shadow: 0 0 0 3px var(--c-brand); }

/* Rule of thirds, only while dragging. */
.pt-crop__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  background-image:
    linear-gradient(to right, transparent calc(33.333% - 0.5px), rgb(255 255 255 / 0.75) calc(33.333% - 0.5px), rgb(255 255 255 / 0.75) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px), transparent calc(66.667% - 0.5px), rgb(255 255 255 / 0.75) calc(66.667% - 0.5px), rgb(255 255 255 / 0.75) calc(66.667% + 0.5px), transparent calc(66.667% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.333% - 0.5px), rgb(255 255 255 / 0.75) calc(33.333% - 0.5px), rgb(255 255 255 / 0.75) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px), transparent calc(66.667% - 0.5px), rgb(255 255 255 / 0.75) calc(66.667% - 0.5px), rgb(255 255 255 / 0.75) calc(66.667% + 0.5px), transparent calc(66.667% + 0.5px));
}

.pt-crop.is-dragging .pt-crop__grid { opacity: 1; }

/* Handles: invisible 44 px+ targets with a visible grip drawn inside. */
.pt-crop__h {
  position: absolute;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  touch-action: none;
  z-index: 2;
}

.pt-crop__h::before { content: ""; position: absolute; }
.pt-crop__h:focus { outline: none; }

.pt-crop__h:focus-visible::after {
  content: "";
  position: absolute;
  inset: 0.35rem;
  border-radius: 9999px;
  box-shadow: 0 0 0 3px var(--c-brand);
}

/* Corners: centred on the box's corner, a thick white L. */
.pt-crop__h--tl, .pt-crop__h--tr, .pt-crop__h--bl, .pt-crop__h--br { width: 3rem; height: 3rem; z-index: 3; }
.pt-crop__h--tl { left: -1.5rem; top: -1.5rem; cursor: nwse-resize; }
.pt-crop__h--tr { right: -1.5rem; top: -1.5rem; cursor: nesw-resize; }
.pt-crop__h--bl { left: -1.5rem; bottom: -1.5rem; cursor: nesw-resize; }
.pt-crop__h--br { right: -1.5rem; bottom: -1.5rem; cursor: nwse-resize; }

.pt-crop__h--tl::before, .pt-crop__h--tr::before, .pt-crop__h--bl::before, .pt-crop__h--br::before {
  width: 1.4rem;
  height: 1.4rem;
  border: 0 solid #fff;
  filter: drop-shadow(0 0 1.5px rgb(15 23 42 / 0.8));
}

.pt-crop__h--tl::before { left: calc(50% - 3px); top: calc(50% - 3px); border-top-width: 5px; border-left-width: 5px; }
.pt-crop__h--tr::before { right: calc(50% - 3px); top: calc(50% - 3px); border-top-width: 5px; border-right-width: 5px; }
.pt-crop__h--bl::before { left: calc(50% - 3px); bottom: calc(50% - 3px); border-bottom-width: 5px; border-left-width: 5px; }
.pt-crop__h--br::before { right: calc(50% - 3px); bottom: calc(50% - 3px); border-bottom-width: 5px; border-right-width: 5px; }

/* Sides: a strip along the whole edge (between the corners), a pill grip. */
.pt-crop__h--t, .pt-crop__h--b { left: 1.5rem; right: 1.5rem; width: auto; cursor: ns-resize; }
.pt-crop__h--l, .pt-crop__h--r { top: 1.5rem; bottom: 1.5rem; height: auto; cursor: ew-resize; }
.pt-crop__h--t { top: -1.375rem; }
.pt-crop__h--b { bottom: -1.375rem; }
.pt-crop__h--l { left: -1.375rem; }
.pt-crop__h--r { right: -1.375rem; }

.pt-crop__h--t::before, .pt-crop__h--b::before {
  left: calc(50% - 1rem);
  top: calc(50% - 3px);
  width: 2rem;
  height: 6px;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 0 2px rgb(15 23 42 / 0.8);
}

.pt-crop__h--l::before, .pt-crop__h--r::before {
  top: calc(50% - 1rem);
  left: calc(50% - 3px);
  width: 6px;
  height: 2rem;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 0 2px rgb(15 23 42 / 0.8);
}

.pt-crop__loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgb(15 23 42 / 0.45);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  padding: 1rem;
  cursor: progress;
}

.pt-crop__spinner {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  border: 3px solid rgb(255 255 255 / 0.35);
  border-top-color: #fff;
  animation: pt-spin 0.8s linear infinite;
}

@keyframes pt-spin { to { transform: rotate(360deg); } }

.pt-crop__readout { font-size: 0.875rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }

.pt-crop__exact { border: 1px solid var(--c-line); border-radius: 0.875rem; padding: 0.7rem 0.9rem; background: var(--c-surface); }
.pt-crop__exact summary { cursor: pointer; font-weight: 650; font-size: 0.9375rem; color: var(--c-ink); }
.pt-crop__exact[open] summary { margin-bottom: 0.75rem; }
.pt-crop__exact .pt-field__hint { margin-top: 0.6rem; }

.pt-crop__exact-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .pt-crop__exact-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.pt-crop__actions .pt-run { margin-top: 0.25rem; }

@media (max-width: 520px) {
  .pt-crop__bar { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .pt-crop__grid { transition: none; }
  .pt-crop__spinner { animation-duration: 2.4s; }
}
