:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f9fafb;
  --blue: #2563eb;
  --green: #15803d;
  --red: #b91c1c;
  --radius: 14px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-size: 15px;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

a {
  color: inherit;
}

.container {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

/* Header and navigation */

.site-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.header-inner {
  width: min(1120px, calc(100% - 40px));
  min-height: 72px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 30px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.brand-logo {
  display: block;
  width: 190px;
  max-width: 100%;
  height: auto;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
}

.top-nav a,
.site-footer a {
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
}

.top-nav a:hover,
.site-footer a:hover {
  color: #111827;
}

/* Product introduction */

.page-intro {
  padding: 56px 0 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .13em;
}

.page-intro h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.15;
  letter-spacing: -.045em;
}

.intro-copy {
  max-width: 760px;
  margin: 16px 0 18px;
  color: #4b5563;
  font-size: 17px;
}

.trust-points {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  color: #4b5563;
  font-size: 13px;
}

.trust-points i {
  margin-right: 5px;
  color: var(--green);
  font-style: normal;
  font-weight: 800;
}

/* Shared buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}

.button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.button-primary {
  background: #111827;
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: #293548;
}

.button-secondary {
  border-color: #d1d5db;
  background: #fff;
  color: #111827;
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  background: #f3f4f6;
}

.button-quiet {
  border-color: var(--line);
  background: transparent;
  color: #4b5563;
}

.danger-text {
  color: var(--red);
}

/* Upload area */

.tool-section {
  padding-bottom: 56px;
}

.upload-panel {
  min-height: 260px;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed #cbd5e1;
  border-radius: 16px;
  background: #fafbfc;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.upload-panel.drag-over {
  border-color: var(--blue);
  background: #eff6ff;
}

.upload-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 10px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #eef2f7;
}

.upload-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #374151;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-panel h2 {
  margin: 0 0 2px;
  font-size: 18px;
}

.upload-panel p {
  margin: 2px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.format-note {
  margin: 12px 0 0 !important;
  font-size: 12px !important;
}

/* Privacy information */

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 16px 0 30px;
  padding: 14px 16px;
  border: 1px solid #dcfce7;
  border-radius: 11px;
  background: #f0fdf4;
}

.privacy-icon {
  font-size: 17px;
}

.privacy-note p {
  margin: 0;
  color: #365744;
  font-size: 13px;
}

.privacy-note strong {
  color: #14532d;
}

/* Workspace panels */

.crop-editor-panel,
.result-panel {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.workspace-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.workspace-tools .button {
  min-height: 36px;
  padding: 7px 12px;
}

/* Main crop editor */

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 22px;
  align-items: start;
  margin-top: 22px;
}

.preview-column {
  min-width: 0;
}

.stage-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.stage-label {
  font-size: 13px;
  font-weight: 700;
}

.stage-hint,
.interaction-hint {
  color: var(--muted);
  font-size: 11px;
}

.stage-viewport {
  min-height: 360px;
  max-height: 680px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background-color: #f3f4f6;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.image-stage {
  position: relative;
  flex: 0 1 auto;
  max-width: 100%;
  line-height: 0;
  user-select: none;
}

.image-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(62vh, 620px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.stage-empty {
  padding: 45px 15px;
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
}

.interaction-hint {
  margin: 10px 0 0;
}

/* Crop selection */

.crop-box {
  position: absolute;
  z-index: 2;
  border: 1px solid #fff;
  outline: 1px solid rgba(37, 99, 235, .95);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, .57);
  cursor: move;
  touch-action: none;
}

.crop-box:focus-visible {
  outline: 2px solid #2563eb;
}

.crop-handle {
  position: absolute;
  z-index: 3;
  width: 12px;
  height: 12px;
  border: 1.5px solid #2563eb;
  border-radius: 3px;
  background: #fff;
  transform: translate(-50%, -50%);
  touch-action: none;
}

.handle-nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.handle-n {
  top: 0;
  left: 50%;
  cursor: ns-resize;
}

.handle-ne {
  top: 0;
  left: 100%;
  cursor: nesw-resize;
}

.handle-e {
  top: 50%;
  left: 100%;
  cursor: ew-resize;
}

.handle-se {
  top: 100%;
  left: 100%;
  cursor: nwse-resize;
}

.handle-s {
  top: 100%;
  left: 50%;
  cursor: ns-resize;
}

.handle-sw {
  top: 100%;
  left: 0;
  cursor: nesw-resize;
}

.handle-w {
  top: 50%;
  left: 0;
  cursor: ew-resize;
}

/* Crop settings */

.crop-controls {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
}

.control-group {
  margin-bottom: 19px;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.control-label {
  display: block;
  margin-bottom: 8px;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

.control-label-row .control-label {
  margin: 0;
}

.unit-label {
  color: #9ca3af;
  font-size: 10px;
}

.control-select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.control-select:focus,
.number-field input:focus {
  outline: 2px solid #bfdbfe;
  border-color: #60a5fa;
}

.control-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.number-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.number-field {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
}

.number-field span {
  min-width: 34px;
  color: #6b7280;
  font-size: 11px;
}

.number-field input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 5px 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.quality-row {
  margin-top: -4px;
}

.quality-row output {
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quality-range {
  width: 100%;
  accent-color: var(--blue);
}

.crop-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 16px;
  padding: 11px 12px;
  border: 1px solid #dbeafe;
  border-radius: 9px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 11px;
}

.crop-summary strong {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.control-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-actions .button {
  width: 100%;
  padding-inline: 9px;
}

.crop-status {
  min-height: 34px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 11px;
}

/* Cropped result */

.editable-label {
  padding: 4px 8px;
  border-radius: 20px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 11px;
  font-weight: 650;
}

.result-preview {
  min-height: 150px;
  max-height: 520px;
  margin-top: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: #f3f4f6;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.result-preview img {
  display: block;
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.result-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.result-hint {
  color: var(--muted);
  font-size: 11px;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

/* Instructions and FAQ */

.content-section {
  padding: 10px 0 60px;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 46px;
  padding: 30px 0;
  border-top: 1px solid var(--line);
}

.content-grid h2,
.faq-section h2 {
  margin-top: 0;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.content-grid p,
.content-grid li,
.faq-section p {
  color: #4b5563;
  font-size: 14px;
}

.content-grid ol {
  padding-left: 20px;
}

.content-grid li {
  padding: 4px 0;
}

.faq-section {
  max-width: 860px;
}

.faq-section h2 {
  margin-bottom: 12px;
}

.faq-section details {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.faq-section summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.faq-section p {
  margin: 8px 0 2px;
}

/* Related tool and footer */

.related-section {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f9fafb;
}

.related-inner {
  padding: 30px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.related-inner h2 {
  margin: 0 0 5px;
  font-size: 20px;
  letter-spacing: -.02em;
}

.related-inner p:not(.eyebrow) {
  margin: 0;
  color: #4b5563;
  font-size: 13px;
}

.related-inner .eyebrow {
  margin-bottom: 5px;
}

.site-footer {
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  color: #9ca3af;
  font-size: 12px;
}

.footer-inner nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.site-footer a {
  font-size: 12px;
}

/* Toast and accessibility */

.toast {
  position: fixed;
  z-index: 20;
  bottom: 22px;
  left: 50%;
  max-width: min(90vw, 520px);
  padding: 10px 15px;
  border-radius: 9px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity .2s, transform .2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript-note {
  margin: 20px auto;
  padding: 12px;
  max-width: 800px;
  color: var(--red);
  text-align: center;
}

/* Tablet */

@media (max-width: 900px) {
  .editor-layout {
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 14px;
  }

  .crop-editor-panel,
  .result-panel {
    padding: 16px;
  }

  .crop-controls {
    padding: 14px;
  }

  .stage-viewport {
    min-height: 300px;
    padding: 12px;
  }
}

/* Mobile */

@media (max-width: 800px) {
  .header-inner {
    padding: 12px 0;
    min-height: 0;
    flex-wrap: wrap;
    gap: 10px 18px;
  }

  .top-nav {
    order: 3;
    width: 100%;
    margin: 0;
    gap: 18px;
  }

  .page-intro {
    padding: 40px 0 24px;
  }

  .intro-copy {
    font-size: 15px;
  }

  .trust-points {
    gap: 8px 16px;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .crop-controls {
    padding: 16px;
  }

  .stage-viewport {
    min-height: 250px;
    max-height: 560px;
  }

  .image-stage img {
    max-height: 55vh;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .related-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .related-inner .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .container,
  .header-inner {
    width: calc(100% - 28px);
  }

  .brand-logo {
    width: 155px;
  }

  .top-nav a {
    font-size: 12px;
  }

  .page-intro h1 {
    font-size: 34px;
  }

  .upload-panel {
    min-height: 235px;
    padding: 24px 14px;
  }

  .workspace-heading {
    display: block;
  }

  .workspace-tools {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .stage-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .stage-viewport {
    min-height: 210px;
    padding: 8px;
  }

  .crop-controls {
    padding: 13px;
  }

  .control-actions {
    grid-template-columns: 1fr;
  }

  .result-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .action-buttons {
    width: 100%;
  }

  .action-buttons .button {
    flex: 1;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .footer-inner nav {
    gap: 10px 16px;
  }
}
