* {
  box-sizing: border-box;
}
:root {
  --primary: #3330F9;
  --primary-dark: #0A06DF;
  --primary-bg: #E7E6FE; 
  --primary-subtle: #C3C2FD; 
  --text: #202124;
  --muted: #68707a;
  --border: #dedfe3;
  --background: #f7f7f8;
  --soft: #f0f0f2;
  --success: #18794e;
  --danger: #b42318;
  --white: #ffffff;
  --crop-line: rgba(255, 255, 255, 0.88);
}
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--background);
  line-height: 1.55;
}
button,
input,
select {
  font: inherit;
}

.float-backhome {
  .back-link {
    padding: 0.5rem;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    vertical-align: middle;
    gap: 0.5rem;
    color: var(--primary);
    border-radius: 0.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    line-height: 1;
    span {
      font-size: 1rem;
    }
    &:hover {
      background-color: var(--primary-bg);
    }
  }
}

@media (min-width: 990px) {
  .float-backhome {
    position: fixed;
    top: 1rem;
  }
}

.grid-container {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 900px) minmax(0, 1fr);
  gap: 24px;
  /* padding: 40px 24px 70px; */
}
.container {
  min-width: 0;
}
.ads {
  min-width: 0;
}
.tool {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(32, 33, 36, 0.06);
  overflow: hidden;
}
.site-header {
  text-align: center;
  padding: 36px 20px 28px;
}

.site-header h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.2;
}

.site-header p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}
.tool-section {
  padding: 1.5rem;
}
.tool-section + .tool-section {
  border-top: 1px solid var(--border);
}
.tool-section h2 {
  margin: 0 0 18px;
  font-size: 22px;
  line-height: 1.3;
}
.dropzone {
  min-height: 250px;
  padding: 32px 24px;
  border: 2px dashed #cfd1d8;
  border-radius: 14px;
  background: #fbfbfc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
  border-color: var(--primary);
  background: #f7f7ff;
  outline: none;
}
.dropzone-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: #ededff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size:1.5rem;
  font-weight: bold;
}

.dropzone-icon span {
  color: var(--primary) !important;
}

.dropzone strong {
  font-size: 18px;
  margin-bottom: 3px;
}
.dropzone span,
.dropzone small {
  color: var(--muted);
}
.dropzone small {
  margin-top: 8px;
}
.choose-btn,
.primary-btn,
.secondary-btn {
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
}
.choose-btn {
  margin-top: 18px;
  padding: 10px 18px;
  color: var(--white);
  background: var(--primary);
}
.choose-btn:hover,
.primary-btn:hover {
  background: var(--primary-dark);
}
.editor {
  margin-top: 24px;
}
.editor-toolbar {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  background: #fff;
}
.form-group {
  margin: 0 0 20px;
}
.editor-toolbar .form-group {
  margin-bottom: 0;
}
.form-group:last-child {
  margin-bottom: 0;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}
.unit {
  color: var(--muted);
  font-weight: normal;
  font-size: 13px;
}
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.ratio-btn {
  min-height: 72px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.ratio-btn:hover {
  border-color: #aaaed0;
  background: #fafaff;
}
.ratio-btn[aria-checked="true"] {
  border-color: var(--primary);
  background: #f7f7ff;
  box-shadow: 0 0 0 2px rgba(91, 91, 240, 0.12);
}
.ratio-icon {
  display: block;
  width: 30px;
  height: 22px;
  border: 2px solid currentColor;
  border-radius: 3px;
  opacity: 0.72;
}
.ratio-icon.square {
  width: 22px;
}
.ratio-icon.portrait {
  width: 19px;
  height: 25px;
}
.ratio-icon.tall {
  width: 17px;
  height: 27px;
}
.ratio-icon.wide {
  width: 34px;
  height: 19px;
}
.ratio-icon.ultrawide {
  width: 37px;
  height: 16px;
}
.ratio-icon.custom {
  width: 37px;
  height: 12px;
}
.ratio-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.ratio-description {
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}
.custom-ratio {
  margin-top: 18px;
  padding: 16px;
  border-radius: 9px;
  background: var(--soft);
}
.custom-ratio-fields {
  display: flex;
  align-items: end;
  gap: 10px;
}
.form-group.compact {
  flex: 1;
  margin: 0;
}
.multiply {
  padding-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}
.form-group input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
}
.custom-ratio-result {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.custom-ratio-result.valid {
  color: var(--text);
  font-weight: 600;
}
.custom-ratio-result.invalid {
  color: var(--danger);
}
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(91, 91, 240, 0.25);
  outline-offset: 2px;
}
.preview-wrap {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #202124;
  overflow: hidden;
}
.image-stage {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  touch-action: none;
  user-select: none;
}
#sourceImage {
  display: block;
  max-width: 100%;
  max-height: 620px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.crop-box {
  position: absolute;
  border: 1px solid var(--crop-line);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.54);
  cursor: move;
  touch-action: none;
}
.crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}
.crop-grid::before,
.crop-grid::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.crop-grid::before {
  left: 33.333%;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: calc(100% - 1px) 0 0 rgba(255, 255, 255, 0.55);
}
.crop-grid::after {
  top: 33.333%;
  left: 0;
  right: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 calc(100% - 1px) 0 rgba(255, 255, 255, 0.55);
}
.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid #fff;
  background: var(--primary);
  border-radius: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.handle-nw {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}
.handle-n {
  left: 50%;
  top: 0;
  cursor: ns-resize;
}
.handle-ne {
  left: 100%;
  top: 0;
  cursor: nesw-resize;
}
.handle-e {
  left: 100%;
  top: 50%;
  cursor: ew-resize;
}
.handle-se {
  left: 100%;
  top: 100%;
  cursor: nwse-resize;
}
.handle-s {
  left: 50%;
  top: 100%;
  cursor: ns-resize;
}
.handle-sw {
  left: 0;
  top: 100%;
  cursor: nesw-resize;
}
.handle-w {
  left: 0;
  top: 50%;
  cursor: ew-resize;
}
.crop-move {
  position: absolute;
  inset: 12px;
  z-index: 2;
  cursor: move;
}
.crop-info {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 13px;
}
.crop-info div {
  display: flex;
  align-items: baseline;
  gap: 9px;
}
.crop-info strong {
  color: var(--text);
  font-size: 15px;
}
.crop-info span {
  color: var(--muted);
}
.output-settings {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}
.privacy-note {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 9px;
  background: #f4faf7;
  color: var(--success);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
}
.privacy-note span {
  color: #476257;
}
.actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.primary-btn,
.secondary-btn {
  padding: 11px 18px;
}
.primary-btn {
  color: var(--white);
  background: var(--primary);
}
.secondary-btn {
  color: var(--text);
  background: var(--soft);
}
.secondary-btn:hover {
  background: #e5e5e8;
}
.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.status {
  min-height: 24px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}
.status.error {
  color: var(--danger);
}
.status.success {
  color: var(--success);
}

.faq-content-section {
  margin-top: 32px;
  padding: 0 4px;
}

.faq-content-section h2 {
  margin: 0 0 10px;
  font-size: 25px;
}

.faq-content-section h3 {
  margin: 26px 0 7px;
  font-size: 19px;
}

.faq-content-section p,
.faq-content-section li {
  color: #454a51;
}

.faq-content-section h2:not(:first-child)  {
  margin-top:30px;
}

footer {
  margin-top: auto;
  padding: 18px;
  text-align: center;
  background: #ededee;
  color: #30343a;
}

@media (max-width: 1180px) {
  .ads {
    display: none;
  }
  .grid-container {
    grid-template-columns: minmax(0, 900px);
    justify-content: center;
    padding-left: 16px;
    padding-right: 16px;
  }
}
@media (max-width: 700px) {
  .ratio-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .output-settings {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .grid-container {
    padding: 12px 10px 40px;
  }
  .tool-header,
  .tool-section {
    padding: 24px 18px;
  }
  .tool-header h1 {
    font-size: 28px;
  }
  .dropzone {
    min-height: 220px;
  }
  .ratio-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .editor-toolbar {
    padding: 16px;
  }
  .preview-wrap {
    padding: 10px;
  }
  .image-stage {
    min-height: 200px;
  }
  .crop-handle {
    width: 16px;
    height: 16px;
  }
  .crop-info {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
  .custom-ratio-fields {
    gap: 7px;
  }
  .actions {
    flex-direction: column;
  }
  .primary-btn,
  .secondary-btn {
    width: 100%;
  }
}
