:root {
  --accent: #7c3aed;
  --ink: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --bg: #f4f4f5;
  --card-bg: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.06), 0 8px 24px rgba(24, 24, 27, 0.08);
  --shadow-hover: 0 4px 10px rgba(24, 24, 27, 0.08), 0 20px 45px rgba(24, 24, 27, 0.16);
  --green: #16a34a;
  --red: #dc2626;
  --dark: #18181b;
  --header-height: 64px;
}

* {
  box-sizing: border-box;
}

/* Several elements below also set their own `display` (e.g. flex, for
   layout), which as an author-stylesheet rule would otherwise override the
   browser's default `[hidden] { display: none }` UA rule. Re-assert it
   explicitly so toggling the `hidden` attribute always actually hides. */
[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Offsets the fixed .site-header so it never overlaps page content -
     .header-inner's min-height matches this same variable exactly. No
     page renders a tools-bar anymore (removed site-wide), so this is
     the only offset every page needs. */
  padding-top: var(--header-height);
}

/* ---------- Fixed header + nav ---------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--card-bg);
  /* box-shadow instead of border-bottom: a 1px hairline that doesn't add to
     the element's layout height, so --header-height stays the single exact
     source of truth for both .header-inner's min-height and body's
     padding-top (a real border would add 1px only to the former). */
  box-shadow: 0 1px 0 var(--border);
}

.header-inner {
  max-width: 1100px;
  min-height: var(--header-height);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
}

.brand {
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--ink);
}

.site-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
}

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

.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2rem;
}

.footer-brand {
  flex: 1 1 240px;
  max-width: 320px;
}

.footer-logo {
  height: 26px;
  width: auto;
  display: block;
  margin-bottom: 0.5rem;
}

.footer-tagline {
  margin: 0;
  line-height: 1.5;
}

.footer-links,
.footer-trust {
  flex: 1 1 200px;
  max-width: 280px;
}

.footer-heading {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.footer-links {
  display: flex;
  flex-direction: column;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0;
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-trust p {
  margin: 0;
  line-height: 1.5;
}

.footer-bottom {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1rem 1.5rem 1.5rem;
  font-size: 0.8rem;
}

.footer-bottom p {
  margin: 0;
}

/* ---------- Hero (circle-crop.html only) ---------- */

.hero {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--border);
}

.breadcrumb-current {
  color: var(--ink);
  font-weight: 600;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 1rem;
  color: var(--ink);
}

.hero-subtitle {
  max-width: 640px;
  margin: 0 auto 1.25rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--muted);
}

.hero-tag {
  margin: 0 0 1.5rem;
}

.tag-pill {
  display: inline-block;
  background: rgba(124, 58, 237, 0.1);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
}

/* ---------- Homepage tool suite (landing.html only) ---------- */

.tool-search-wrap {
  max-width: 420px;
  margin: 0 auto;
}

.tool-search-input {
  width: 100%;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--ink);
  font-size: 0.95rem;
  box-shadow: var(--shadow);
}

.tool-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

/* Slim row of shortcut pills right under the hero on landing.html -
   scrolls with the page and only ever lists the live tools. */
.quick-tools-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  max-width: 900px;
  margin: 0 auto 1rem;
  padding: 0 1.5rem;
}

.quick-tools-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.quick-tools-item:hover,
.quick-tools-item:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(124, 58, 237, 0.35);
}

.quick-tools-item svg {
  display: block;
  flex-shrink: 0;
  color: var(--accent);
}

/* Small "Soon" pill next to a coming-soon card's title - the card itself
   is already dimmed via .blog-card--soon's opacity, this just labels why. */
.soon-badge {
  display: inline-block;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.3rem;
}

/* ---------- Simple content pages (Terms / Privacy / Contact) ---------- */

.page-content {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  line-height: 1.65;
}

.page-content h1 {
  font-size: 1.8rem;
  margin: 0 0 0.75rem;
}

.page-content h2 {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
}

.page-content p {
  margin: 0.75rem 0;
}

.page-content a {
  color: var(--accent);
}

.page-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0 !important;
}

/* ---------- Contact form (contact.html only) ---------- */


.contact-form-section h2 {
  font-size: 1.15rem;
  margin: 0 0 1rem;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  width: 100%;
  max-width: 480px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.required-mark {
  color: var(--red);
}

.form-field input,
.form-field textarea {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.form-field textarea {
  resize: vertical;
  min-height: 100px;
}

.form-field input[aria-invalid="true"],
.form-field textarea[aria-invalid="true"] {
  border-color: var(--red);
}

.field-error {
  margin: 0;
  color: #b91c1c;
  font-size: 0.82rem;
}

.form-status {
  margin: 0;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.form-status-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.form-status-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

#cf-submit {
  align-self: flex-start;
}

/* ---------- Error text (shared) ---------- */

.error-text {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  max-width: 640px;
  margin: 0.5rem auto 0;
  text-align: center;
}

/* ---------- Two-panel workspace ---------- */

.workspace {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  /* Without this, .panel's automatic minimum width defaults to its
     content's min-content size - and Cropper.js sets an inline pixel
     width on its dynamically-inserted .cropper-container based on the
     source image's natural size, which can be much wider than the
     available grid column (e.g. on narrow/mobile viewports). That content
     minimum then forces the whole grid track (and .panel) to blow out and
     overflow the page horizontally. min-width: 0 removes that floor so
     .panel (and .stage below) actually shrink to the grid/flex space
     they're given, letting .stage's overflow: hidden clip the rest. */
  min-width: 0;
}

.panel-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.panel-right .panel-top {
  justify-content: flex-start;
}

.result-label {
  font-weight: 700;
  font-size: 1rem;
}

.panel-bottom .btn {
  width: 100%;
}

/* Left panel's top row holds two buttons side by side - UPLOAD IMAGE
   gets more room than the secondary "Use demo image" button. */
.panel-left .panel-top #upload-btn {
  flex: 2;
}

.panel-left .panel-top #demo-btn {
  flex: 1;
}

/* ---------- Avatar tool controls (avatar-crop.html; container classes
   .avatar-controls/.avatar-control-group/.avatar-control-label are also
   reused as-is by crop-image.html's ratio-preset row - only the toggle
   button styling below is tool-specific per group) ---------- */

.avatar-controls {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0.9rem;
  background: var(--bg);
  border-radius: 10px;
}

.avatar-control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.avatar-control-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

/* A muted, non-bold aside inside an .avatar-control-label, e.g.
   "(or drag on the preview)" next to "Position". */
.control-hint {
  font-weight: 400;
  color: var(--muted);
}

.shape-toggle {
  display: inline-flex;
  background: var(--card-bg);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.2rem;
  width: fit-content;
}

.shape-toggle-btn {
  border: none;
  background: none;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.shape-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

.shape-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Aspect-ratio preset row (crop-image.html only) - individually chip-
   shaped buttons rather than .shape-toggle's single fixed-width pill,
   because there are up to 6 of these (Free, 1:1, 4:3, 3:2, 16:9, 9:16)
   and they need to wrap onto a second line at narrow widths instead of
   being squeezed into one non-wrapping bar. */
.ratio-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ratio-toggle-btn {
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ratio-toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ratio-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.border-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  width: fit-content;
}

.border-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.border-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.15rem;
}

.color-swatches {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 0 1px var(--border);
  flex-shrink: 0;
}

.color-swatch.active {
  box-shadow: 0 0 0 2px var(--accent);
}

.color-swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#border-color-picker {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

/* Same circular color-input treatment as #border-color-picker above,
   under a reusable class so any future tool's color picker (not just
   the border one) gets it without a page-specific ID rule. */
.color-picker-circle {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

.border-thickness-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.border-thickness-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.border-thickness-row span {
  min-width: 3.2em;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
}

.avatar-size-select {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--ink);
  font-size: 0.85rem;
  width: fit-content;
}

/* Same look as .avatar-size-select, sized to fill its row instead of
   fitting its content - a plain text field for any control panel that
   needs one (e.g. add-watermark's watermark-text input). */
.text-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--ink);
  font-size: 0.85rem;
  font-family: inherit;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

/* Generic control-row helpers - a wrapped row of buttons, and a
   range-slider-plus-value-readout row (same layout as
   .border-thickness-row above, just under a tool-neutral name since
   rotate-crop and irregular-crop both need this shape and neither is
   about a border). Shared across any future tool's control panel. */
.control-btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.control-slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.control-slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.control-slider-row span {
  min-width: 3.2em;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
}

/* Live shape + colored-border preview for the avatar tool - same
   insertion point/technique as .shape-overlay-svg (a child of
   .cropper-crop-box, right after .cropper-view-box), but rebuilt on
   demand from js/app-avatar.js's updateOverlay() whenever the shape,
   border toggle, color, or thickness changes, rather than being fixed
   once like the single-shape tools. */
.avatar-overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}

/* ---------- Stages (editor / result) ---------- */

.stage {
  position: relative;
  height: 420px;
  min-width: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #e4e4e7;
}

#result-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Generic centered-preview stage - for tools with no Cropper.js crop
   box and no interactive canvas either, just a plain image shown for
   reference (image-to-sketch's original-image preview). Same
   flex-centering .stage already gives #result-stage, under a
   tool-neutral name so any future plain-preview tool can reuse it. */
.stage-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.stage-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

.stage-placeholder {
  margin: 0;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

#editor-stage .stage-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#result-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Perspective Crop's interactive editor canvas (perspective-crop.html
   only) - draws the image plus the draggable 4-corner quad overlay
   itself, in place of the Cropper.js-driven <img> every other tool
   uses. touch-action: none is required so a touch-drag on a handle
   moves the handle instead of being hijacked by the browser's own
   scroll/pinch-zoom gesture handling. */
#editor-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

/* Small always-visible helper line under a control group's label (e.g.
   irregular-crop's "Draw your shape") - a permanent fallback for users
   who miss or dismiss the #draw-hint overlay's timed fade below. */
.control-tip {
  margin: -0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* remove-background.html's progress/loading indicator - shown while the
   AI model downloads (first use only) and while it's actually running
   inference, so the multi-second wait never looks frozen. */
.bg-remove-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.spinner {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: bg-remove-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  /* A loading spinner is functional, not decorative - slowed down
     rather than removed entirely, unlike purely ornamental animations
     elsewhere on the site, so reduced-motion users still get a visible
     "this is still working" cue. */
  .spinner {
    animation-duration: 2.4s;
  }
}

/* Narrower/left-aligned override of the shared .error-text look (which
   defaults to a wide, centered block meant for full-page placement) -
   this one sits inside a narrow left-panel control group instead. */
.bg-remove-error {
  margin: 0;
  max-width: none;
  text-align: left;
}

/* remove-background.html's manual brush-refine layer, painted directly
   onto #result-canvas after the AI cutout is ready. A dedicated class
   (not the shared #result-canvas rule, which several other tools'
   non-interactive result canvases also use) so `touch-action: none`
   and the hidden native cursor only ever apply here - giving those
   other tools' plain output canvases `touch-action: none` too would
   block page-scroll gestures starting on them for no reason. */
.brush-canvas {
  touch-action: none;
  cursor: none;
  /* Needs to be a positioned element so #ghost-canvas (position:
     absolute) reliably stacks BELOW it - CSS paints positioned
     elements above static ones within the same stacking context
     regardless of DOM order, so #ghost-canvas would otherwise cover
     the real result even though it comes first in the markup.
     position: relative with no offset is layout-neutral - it changes
     nothing about how this canvas is sized or flows. */
  position: relative;
  z-index: 2;
}

/* The ghost-preview layer (Restore mode's "what's under here" guide) -
   a second canvas holding a low-opacity copy of the ORIGINAL image,
   absolutely positioned to exactly overlay #result-canvas and kept
   BELOW it in the stack (z-index 1 vs. 2). This is a pure display
   trick, not a data trick: wherever the real result canvas on top is
   transparent, this faint layer shows through beneath it; wherever
   the result is opaque, it fully covers the ghost. #result-canvas's
   own pixels are never touched by this - js/app-remove-background.js
   keeps this canvas's on-screen position/size synced to #result-
   canvas's own rendered box (getBoundingClientRect), since the stage
   centers #result-canvas via flex layout that an absolutely-
   positioned sibling doesn't automatically participate in. */
#ghost-canvas {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

/* A DOM element (not the native CSS cursor, which has small OS-level
   size caps and doesn't preview well on touch) that follows the
   pointer and is sized to the current brush diameter in on-screen
   CSS px - js/app-remove-background.js keeps its width/height/
   position in sync on every pointer move. */
.brush-cursor {
  position: absolute;
  border: 2px solid rgba(124, 58, 237, 0.9);
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.15);
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 3;
}

/* irregular-crop.html's onboarding hint - a small floating card centered
   over #editor-stage that appears the moment an image loads, so users
   immediately understand they must trace a shape rather than just look
   at the picture. pointer-events: none is the load-bearing property
   here: the overlay can never intercept a click/tap, so the very first
   press always reaches #editor-canvas underneath and starts the path,
   at the same time as (not after) the hint disappears - no "click once
   to dismiss, click again to draw" required. Visibility is driven by
   the .draw-hint-visible class (toggled from js/app-irregular-crop.js),
   not the `hidden` attribute, so the opacity/transform transition below
   can actually animate instead of snapping instantly. */
.draw-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 2;
}

.draw-hint-visible {
  opacity: 1;
  transform: translateY(0);
}

.draw-hint-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  max-width: 85%;
  padding: 0.9rem 1.1rem;
  background: rgba(24, 24, 27, 0.78);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.draw-hint-text {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.draw-hint-svg {
  color: #fff;
  overflow: visible;
}

/* The traced outline itself - a dashed loop whose dash offset keeps
   animating ("marching ants"), the standard visual convention for "trace
   along this line", so the cue reads as motion without needing a
   separate moving pen/finger glyph to stay subtle. */
.draw-hint-loop {
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 10 8;
  animation: draw-hint-march 1.1s linear infinite;
}

@keyframes draw-hint-march {
  to {
    stroke-dashoffset: -18;
  }
}

@media (prefers-reduced-motion: reduce) {
  .draw-hint-loop {
    animation: none;
  }
}

/* Checkerboard pattern so transparency is visible behind the result. On
   the left, Cropper.js draws its own equivalent pattern automatically
   (via the `background: true` option -> its built-in .cropper-bg class),
   so this is only applied to the right panel's result stage. */
.checkerboard {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d4d4d8 25%, transparent 25%),
    linear-gradient(-45deg, #d4d4d8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d4d4d8 75%),
    linear-gradient(-45deg, transparent 75%, #d4d4d8 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* Drag-and-drop highlight for the editor stage (before an image loads). */
#editor-stage.dragover {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* ---------- Cropper.js overrides ---------- */
/* Recolor the crop box's border lines and all 8 resize handles (4 corner
   + 4 edge-midpoint points) green, and tint the view-box outline to match. */

.cropper-view-box {
  outline-color: rgba(22, 163, 74, 0.85);
}

.cropper-line,
.cropper-point {
  background-color: var(--green);
}

.cropper-point.point-se::before {
  background-color: var(--green);
}

/* Suppress Cropper's own square modal shade ONLY on the circle-crop tool
   (circle-crop.html has <body class="circle-tool">) - the dark fill Cropper
   draws behind the crop box via .cropper-drag-box.cropper-modal - since
   that page's dimming is driven entirely by .crop-circle-overlay's
   box-shadow below, which follows the CIRCLE instead of the square.
   `modal: false` is also set in the Cropper options in js/app.js; this
   CSS override is kept too as a defensive belt-and-suspenders in case
   that option's effect ever changes across a Cropper.js version.
   Deliberately scoped to .circle-tool (not global) so other Cropper.js-
   using pages, like the square-crop tool, keep Cropper's normal default
   square dimming instead of losing it site-wide. */
.circle-tool .cropper-modal {
  background-color: transparent;
  opacity: 0;
}

/* A red circle inscribed in the (always-square, aspectRatio:1) crop box,
   with a huge spread box-shadow that dims everything OUTSIDE the circle
   (including the square's own corners) while leaving the circle's
   interior clear. Appended as a child of .cropper-crop-box (right after
   .cropper-view-box - see addCropCircleOverlay() in js/app.js for why
   not view-box itself), sized to 100% of its parent so it tracks every
   move/resize Cropper performs on the (always-square) crop box. */
.crop-circle-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--red);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
  pointer-events: none;
}

/* Suppress Cropper's own square modal shade on the heart/star/oval shape
   tools too (each of those pages has <body class="shape-tool">) - same
   reasoning as .circle-tool above: their own .shape-overlay-svg (below)
   already darkens everything outside the shape via an SVG mask, so
   Cropper's square dimming would just double up on top of it. `modal:
   false` is also set in js/shape-crop.js's Cropper options; this CSS
   override is kept too as the same defensive belt-and-suspenders as the
   circle tool's. Deliberately scoped to .shape-tool (not global). */
.shape-tool .cropper-modal {
  background-color: transparent;
  opacity: 0;
}

/* Live shape-outline + outside-dimming preview for the heart/star/oval
   tools - one <svg> (built in js/shape-crop.js's addShapeOverlay(),
   inserted at the same DOM position as .crop-circle-overlay above: a
   child of .cropper-crop-box, right after .cropper-view-box) standing in
   for a CSS border-radius trick, since heart/star aren't expressible as a
   border-radius. The SVG's own viewBox + preserveAspectRatio="none"
   handles stretching the shared 0-64 shape definition to fill the crop
   box exactly, whether that box is square (heart/star) or a free-aspect
   rectangle (oval) - no extra CSS sizing math is needed here beyond
   simply filling the parent. */
.shape-overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}

/* ---------- Buttons ---------- */

.btn {
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-dark {
  background: var(--dark);
  color: #fff;
}

.btn-dark:hover:not(:disabled) {
  filter: brightness(1.3);
}

.btn-outline {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: #f4f4f5;
  border-color: var(--accent);
}

.btn-red {
  background: var(--red);
  color: #fff;
}

.btn-red:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-green {
  background: var(--green);
  color: #fff;
}

.btn-green:hover:not(:disabled) {
  filter: brightness(1.08);
}

/* ---------- How-to-use + About/features sections (circle-crop.html only) ---------- */

.howto-section,
.about-section {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.section-subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 2rem;
}

.howto-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
}

.howto-step {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem;
  text-align: center;
  /* Reserve the border's space at rest (transparent) so the hover state
     below can change border-color without shifting the box size/layout. */
  border: 1px solid transparent;
}

.howto-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.howto-step h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--ink);
}

.howto-step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.about-intro {
  max-width: 760px;
  margin: 0 auto 2rem;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  /* Reserve the border's space at rest (transparent) so the hover state
     below can change border-color without shifting the box size/layout. */
  border: 1px solid transparent;
}

/* ---------- Card hover animation (how-to steps + feature cards) ---------- */
/* Shared lift-and-glow hover: both card types already use the same
   resting look (--card-bg/--radius/--shadow), so they share one hover
   treatment rather than duplicating it per class. */
.howto-step,
.feature-card {
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
  will-change: transform;
}

.howto-step:hover,
.howto-step:focus-within,
.feature-card:hover,
.feature-card:focus-within {
  transform: translateY(-6px) scale(1.01);
  box-shadow: var(--shadow-hover);
  border-color: rgba(124, 58, 237, 0.35);
}

/* Users who prefer reduced motion still get the shadow/border change
   (a visible hover state), just with no movement/scale. */
@media (prefers-reduced-motion: reduce) {
  .howto-step,
  .feature-card {
    transition: box-shadow 0.2s ease-out, border-color 0.2s ease-out;
  }

  .howto-step:hover,
  .howto-step:focus-within,
  .feature-card:hover,
  .feature-card:focus-within {
    transform: none;
  }
}

.feature-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--ink);
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ---------- FAQ accordion (every tool page: circle-crop.html,
   crop-square-image.html, heart-crop.html, star-crop.html,
   oval-crop.html) ---------- */
/* Markup starts as plain <h3 class="faq-question"> + <p class="faq-answer">
   pairs (content untouched); js/faq-accordion.js progressively enhances
   each .faq-item into the accordion structure these rules style:
     .faq-item
       .faq-item-heading (h3)
         button.faq-question
           span.faq-question-text
           span.faq-icon
       .faq-answer-wrap (role="region")
         p.faq-answer (the original, untouched answer element, just moved) */

.faq-section {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.faq-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.faq-item-heading {
  margin: 0;
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  background: none;
  border: none;
  margin: 0;
  padding: 1.25rem 1.5rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.faq-question:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.faq-question-text {
  flex: 1;
}

.faq-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--accent);
  transition: transform 0.25s ease;
}

.faq-item.open .faq-icon {
  transform: rotate(45deg);
}

.faq-answer-wrap {
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: max-height 0.25s ease, visibility 0s linear 0.25s;
}

.faq-item.open .faq-answer-wrap {
  visibility: visible;
  transition: max-height 0.25s ease, visibility 0s linear 0s;
}

@media (prefers-reduced-motion: reduce) {
  .faq-icon,
  .faq-answer-wrap {
    transition: none;
  }
}

.faq-answer {
  margin: 0;
  padding: 0 1.5rem 1.25rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- Blog listing (/blog) ---------- */

.blog-listing {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

.blog-listing-header {
  text-align: center;
  margin-bottom: 2rem;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

/* landing.html's #popular-tools-grid renders however many tools are
   flagged `popular: true` in js/tools.js (currently 4 - see the field
   comment up there) - overrides the shared 3-column .blog-grid layout
   with a fixed 2-column one so it reads as an intentional grid rather
   than the wider 3-column layout used for full category sections,
   with a couple of empty columns where a 3rd/4th card would go on a
   short list. Any future change to how many tools are marked popular
   should keep the count a multiple of 2 so this never ends on a
   lopsided single-card row (mobile still collapses to 1 column via
   .blog-grid's own 480px breakpoint below, where row balance isn't a
   concern). Same specificity as .blog-grid, placed right after it so
   normal cascade/source-order still lets .blog-grid's own responsive
   breakpoints (800px/700px) win below this point in the file. */
.tools-grid-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 640px;
  margin: 0 auto;
}

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

.blog-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Reserve the border's space at rest (transparent), same reasoning as
     .howto-step/.feature-card: lets the shared hover rule below change
     border-color without shifting the box size/layout. */
  border: 1px solid transparent;
}

.blog-card-image-link {
  display: block;
}

.blog-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

/* Same top-of-card slot as .blog-card-image, but for tool cards (e.g.
   landing.html) that use a simple inline SVG icon instead of a photo -
   reuses the same .blog-card/.blog-card-body/.blog-card-title/
   .blog-card-description/.blog-card-cta styling and hover animation. */
.tool-card-icon {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 58, 237, 0.08);
}

.blog-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.blog-card-title {
  font-size: 1.05rem;
  margin: 0;
  line-height: 1.35;
}

.blog-card-title a {
  color: var(--ink);
  text-decoration: none;
}

.blog-card-title a:hover {
  color: var(--accent);
}

.blog-card-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  flex: 1;
}

.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.blog-card-meta-sep {
  color: var(--border);
}

.blog-card-cta {
  align-self: flex-start;
  margin-top: 0.25rem;
}

/* Blog cards join the same shared lift-and-glow hover as the how-to-step
   and feature cards - they already share the same resting look (--card-bg/
   --radius/--shadow), so no separate hover treatment is defined here. */
.blog-card {
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
  will-change: transform;
}

.blog-card:hover,
.blog-card:focus-within {
  transform: translateY(-6px) scale(1.01);
  box-shadow: var(--shadow-hover);
  border-color: rgba(124, 58, 237, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .blog-card {
    transition: box-shadow 0.2s ease-out, border-color 0.2s ease-out;
  }

  .blog-card:hover,
  .blog-card:focus-within {
    transform: none;
  }
}

/* Dimmed "coming soon" placeholder card - same shape/rhythm as a real
   tool card, but visually inactive (no lift-on-hover, no CTA button). */
.blog-card--soon {
  opacity: 0.55;
}

.blog-card--soon:hover,
.blog-card--soon:focus-within {
  transform: none;
  box-shadow: var(--shadow);
  border-color: transparent;
}

/* ---------- Blog post page (/blog/<slug>) ---------- */

.post-page {
  flex: 1;
  width: 100%;
  padding: 2.5rem 1.5rem 3rem;
}

.post-article {
  max-width: 760px;
  margin: 0 auto;
}

.post-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.post-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0.75rem 0;
  color: var(--ink);
}

.post-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.post-meta-sep {
  color: var(--border);
}

.post-featured-image {
  width: 100%;
  border-radius: var(--radius);
  display: block;
  margin: 1.5rem 0 2rem;
  box-shadow: var(--shadow);
}

.toc {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 0 0 2rem;
}

.toc-heading {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc-item a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.92rem;
}

.toc-item a:hover {
  text-decoration: underline;
}

.toc-item-h3 {
  padding-left: 1.25rem;
}

.toc-item-h3 a {
  font-size: 0.88rem;
}

.post-body {
  line-height: 1.7;
  color: var(--ink);
}

.post-body h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.75rem;
}

.post-body h2:first-child {
  margin-top: 0;
}

.post-body h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

.post-body p {
  margin: 0 0 1rem;
}

.post-body ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.post-body li {
  margin-bottom: 0.4rem;
}

.post-body a {
  color: var(--accent);
}

.post-share {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.post-share-label {
  margin: 0 0 1rem;
  font-weight: 600;
  color: var(--ink);
}

.related-section {
  max-width: 1100px;
  margin: 3rem auto 0;
  padding: 2rem 1.5rem 0;
  border-top: 1px solid var(--border);
}

.related-section .section-title {
  font-size: 1.4rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .howto-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .blog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Collapse the nav links into a hamburger-toggled dropdown below ~700px. */
@media (max-width: 700px) {
  .nav-toggle {
    display: flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 0.5rem 1.5rem 1rem;
  }

  /* Toggled by js/nav.js - kept open/closed purely via this class so no
     layout shift ever happens on the content below the fixed header. */
  .site-nav.open {
    display: flex;
  }

  .site-nav a {
    width: 100%;
    padding: 0.65rem 0.25rem;
    border-bottom: none;
    border-radius: 8px;
  }

  .site-nav a.active {
    color: var(--accent);
    background: rgba(124, 58, 237, 0.08);
  }

  .footer-inner {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    text-align: center;
    gap: 1.75rem;
  }

  .footer-brand,
  .footer-links,
  .footer-trust {
    flex: none;
    max-width: 100%;
  }

  .footer-links {
    align-items: center;
  }
}

@media (max-width: 480px) {
  .header-inner {
    padding: 0 1rem;
  }

  .brand-logo {
    height: 22px;
  }

  .footer-logo {
    height: 22px;
  }

  .site-nav {
    padding: 0.5rem 1rem 1rem;
  }

  .hero {
    padding: 2rem 1rem 1rem;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .hero-subtitle {
    font-size: 0.92rem;
  }

  .quick-tools-bar {
    padding: 0 1rem;
    gap: 0.4rem;
  }

  .quick-tools-item {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
  }

  .breadcrumb {
    font-size: 0.78rem;
    gap: 0.3rem;
  }

  .workspace {
    padding: 1rem 1rem 1.5rem;
    gap: 1rem;
  }

  .panel {
    padding: 1rem;
  }

  .stage {
    height: 320px;
  }

  .panel-left .panel-top {
    flex-direction: column;
  }

  .panel-left .panel-top #upload-btn,
  .panel-left .panel-top #demo-btn {
    flex: none;
    width: 100%;
  }

  .avatar-controls {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .howto-section,
  .about-section,
  .faq-section {
    padding: 2rem 1rem;
  }

  .section-title {
    font-size: 1.35rem;
  }

  .howto-steps,
  .feature-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .footer-inner {
    padding: 2rem 1rem 1.25rem;
    gap: 1.5rem;
  }

  .footer-bottom {
    padding: 1rem 1rem 1.25rem;
  }

  .blog-listing {
    padding: 2rem 1rem 2rem;
  }

  .blog-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .post-page {
    padding: 2rem 1rem 2rem;
  }

  .post-title {
    font-size: 1.5rem;
  }

  .toc {
    padding: 1rem 1.25rem;
  }

  .related-section {
    padding: 1.5rem 1rem 0;
  }
}
