/* Crop & Resize — app-specific styles. Shared tokens/components come from
   ../styles.css (dropped beside this app by the build). Spacing scale and
   .tool-hero/.upload-card/.info-panel copied from Compress PDF/app/style.css,
   the catalog's canonical no-scroll-budget source of truth. */

body.shell { --sa-boxed-maxw: 1280px; }
.wrap { max-width: 1280px; padding: 12px 48px 16px; position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* --- Tool hero --- */
.tool-hero { text-align: center; padding: 0 0 8px; }
.tool-hero h1 { font-size: clamp(34px, 3.4vw, 44px); line-height: 1.12; }
.tool-hero-lead { color: var(--muted); font-size: 18px; margin: 6px auto 0; max-width: 640px; }
.tool-hero-trust {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 12px;
  color: #23499e; background: var(--accent-soft); border: 1px solid #c7dafb;
  padding: 9px 18px; border-radius: 999px; font-size: 15px; font-weight: 600;
}
.tool-hero-trust svg { color: var(--accent); flex: none; }
/* Editing state collapses the lead/trust lines to reclaim vertical space. */
.tool-hero.editing .tool-hero-lead,
.tool-hero.editing .tool-hero-trust { display: none; }
.tool-hero.editing { padding-bottom: 6px; }

/* --- Drop zone (empty state) --- */
.dropzone { transition: none; }
.upload-card {
  display: grid; place-items: center; gap: 8px; text-align: center;
  padding: 16px 40px; border: 2px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.dropzone.dragover .upload-card { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow-hover); }
.upload-ic {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.upload-ic svg { width: 26px; height: 26px; }
.upload-card h2 { font-size: 25px; font-weight: 700; }
.upload-card p { color: var(--muted); font-size: 17px; max-width: 500px; }
#pick-file { background: linear-gradient(135deg, #4a84f5, #2f6df0); box-shadow: 0 6px 22px rgba(47,109,240,.35); margin-top: 6px; font-size: 18px; padding: 17px 34px; }

/* --- Trust group (benefit cards + status line), empty state only --- */
.info-panel { margin-top: 8px; }
.info-panel .benefits.grid { margin: 0; gap: 22px; }
.info-panel .card { padding: 14px 22px; transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.info-panel .card h3 { font-size: 20px; margin-bottom: 9px; }
.info-panel .card p { font-size: 16.5px; line-height: 1.5; }
.info-panel .card .ic { width: 46px; height: 46px; border-radius: 12px; margin-bottom: 16px; }
.info-panel .card .ic svg { width: 24px; height: 24px; }
.info-panel .card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: var(--line-strong); }
.info-panel .card .ic { color: #fff; }
.info-panel .card .ic-blue  { background: var(--accent); }
.info-panel .card .ic-amber { background: var(--amber); }
.info-panel .card .ic-green { background: var(--good); }

.privacy { margin: 14px 0 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 15.5px; }
.privacy .dot, .panel-privacy .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.privacy .dot.good, .panel-privacy .dot.good { background: var(--good); box-shadow: 0 0 0 3px rgba(28,164,99,.18); }

/* --- Buttons not covered by shared tokens.css --- */
.btn-ghost { background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); cursor: pointer; }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

/* ==================== Editor state ==================== */
.editor { display: grid; grid-template-columns: 1fr 300px; gap: 22px; margin-top: 6px; align-items: start; }
/* .editor's `display: grid` (author origin) outranks the UA `[hidden]` rule
   (user-agent origin) — see Compress PDF's #download-all[hidden] for the same gotcha. */
.editor[hidden] { display: none; }

.editor-stage { min-width: 0; }
.stage-frame {
  position: relative; max-height: min(58vh, 620px); min-height: 260px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: repeating-conic-gradient(#e9ecf2 0% 25%, #f6f7fa 0% 50%) 0 0 / 22px 22px;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
#src-img { max-width: 100%; max-height: min(58vh, 620px); object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }

.crop-box { position: absolute; touch-action: none; }
.crop-mask { position: absolute; background: rgba(15, 17, 23, .55); pointer-events: none; }
.crop-mask-t { top: -2000px; left: -2000px; right: -2000px; height: 2000px; }
.crop-mask-b { bottom: -2000px; left: -2000px; right: -2000px; height: 2000px; }
.crop-mask-l { top: 0; bottom: 0; left: -2000px; width: 2000px; }
.crop-mask-r { top: 0; bottom: 0; right: -2000px; width: 2000px; }
.crop-box::before {
  content: ""; position: absolute; inset: 0; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none;
}
.crop-rule { position: absolute; background: rgba(255,255,255,.55); pointer-events: none; }
.crop-rule-v1 { top: 0; bottom: 0; left: 33.333%; width: 1px; }
.crop-rule-v2 { top: 0; bottom: 0; left: 66.667%; width: 1px; }
.crop-rule-h1 { left: 0; right: 0; top: 33.333%; height: 1px; }
.crop-rule-h2 { left: 0; right: 0; top: 66.667%; height: 1px; }

.crop-handle { position: absolute; background: #fff; border: 1.5px solid var(--accent); border-radius: 3px; z-index: 2; }
.crop-handle.ch-n, .crop-handle.ch-s { width: 28px; height: 8px; left: 50%; margin-left: -14px; cursor: ns-resize; }
.crop-handle.ch-e, .crop-handle.ch-w { width: 8px; height: 28px; top: 50%; margin-top: -14px; cursor: ew-resize; }
.crop-handle.ch-n { top: -4px; } .crop-handle.ch-s { bottom: -4px; }
.crop-handle.ch-w { left: -4px; } .crop-handle.ch-e { right: -4px; }
.crop-handle.ch-nw, .crop-handle.ch-ne, .crop-handle.ch-sw, .crop-handle.ch-se { width: 14px; height: 14px; border-radius: 50%; }
.crop-handle.ch-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle.ch-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.crop-handle.ch-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle.ch-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }

/* --- Editor side panel --- */
.editor-panel {
  display: flex; flex-direction: column; gap: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.panel-group { display: flex; flex-direction: column; gap: 8px; }
.panel-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

.ratio-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.dim-row { display: flex; align-items: center; gap: 8px; }
.dim-field { display: flex; align-items: center; gap: 6px; flex: 1; font-size: 13px; color: var(--muted); }
.dim-field input {
  width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 8px; font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
}
.dim-field input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dim-warn { color: #92400e; background: #fffaeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin: 0; }

.transform-row { display: flex; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); cursor: pointer; flex: none;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

#opt-format {
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
}

.panel-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.panel-actions .btn { width: 100%; justify-content: center; }
.panel-privacy { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 0; }

/* --- Toast --- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  background: var(--text); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .2s ease, transform .2s ease; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Mobile --- */
@media (max-width: 860px) {
  .editor { grid-template-columns: 1fr; }
  .upload-card { padding: 40px 20px; }
}
