:root {
  color-scheme: dark;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: #f1efff;
  background: #100e1c;
  --accent: #b5a4ff;
  --muted: #b8b3cc;
  --line: #3a324e;
  --soft: #29213f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; display: flex; flex-direction: column; background: radial-gradient(ellipse at 75% 22%, #29183f, transparent 56%); }
h1, h2, h3, p, figure { margin: 0; }
p { color: var(--muted); line-height: 1.65; }
.site-header { background: #191525; border-block-end: 1px solid var(--line); }
.header-inner, main, footer {
  width: min(1180px, calc(100% - 64px));
  margin-inline: auto;
}
.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 1.06rem; }
.mark {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px;
  position: relative; background: var(--accent);
}
.mark::before, .mark::after {
  content: ""; position: absolute; width: 13px; height: 13px;
  border: 2px solid #221737; border-radius: 3px;
}
.mark::before { top: 8px; left: 8px; }
.mark::after { bottom: 7px; right: 7px; background: var(--accent); }
.language-control {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding-inline: 12px 8px;
  border: 1px solid var(--line); border-radius: 12px; background: #191525;
}
.globe {
  width: 17px; height: 17px; border: 1.5px solid currentColor; border-radius: 50%;
  position: relative; color: var(--accent);
}
.globe::before, .globe::after { content: ""; position: absolute; }
.globe::before { inset: -1.5px 3.5px; border: 1.5px solid; border-radius: 50%; }
.globe::after { inset: 6px 0 auto; border-top: 1.5px solid; }
#language {
  min-height: 44px; max-width: 128px; border: 0; background: transparent;
  color: inherit; font: inherit; font-size: .94rem; cursor: pointer;
}
main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr);
  grid-template-areas: "intro example" "workspace example";
  grid-template-rows: auto 1fr;
  align-content: center;
  column-gap: clamp(26px, 5vw, 76px);
  padding-block: clamp(40px, 8vw, 104px) 60px;
}
.intro { grid-area: intro; align-self: end; margin-block-end: 28px; }
h1 {
  font-size: clamp(2.7rem, 5vw, 4.7rem);
  letter-spacing: -.055em;
  line-height: 1.1;
  text-wrap: balance;
}
h1 span { color: #e4dcff; }
[dir="rtl"] h1 { letter-spacing: normal; line-height: 1.25; }
:lang(fr) h1 { font-size: clamp(2.4rem, 4.35vw, 4.1rem); }
.intro p { margin-block-start: 16px; font-size: clamp(1rem, 1.6vw, 1.2rem); }
.workspace { grid-area: workspace; align-self: start; min-width: 0; }
.dropzone {
  text-align: center; padding: 25px 15px 23px; border: 1.5px dashed #6b568d;
  background: #191525; border-radius: 20px; transition: background-color 180ms, border-color 180ms;
}
.dropzone.active { background: var(--soft); border-color: var(--accent); }
.upload-icon {
  width: 50px; height: 50px; margin: 0 auto 11px; display: grid; place-items: center;
  background: var(--soft); color: var(--accent); border-radius: 14px;
}
.upload-icon span {
  width: 21px; height: 12px; margin-top: 9px; position: relative;
  border: 2px solid; border-top: 0; border-radius: 0 0 4px 4px;
}
.upload-icon span::before, .upload-icon span::after { content: ""; position: absolute; left: 50%; }
.upload-icon span::before { top: -9px; width: 2px; height: 13px; background: currentColor; transform: translateX(-50%); }
.upload-icon span::after {
  width: 7px; height: 7px; top: -9px; border: solid; border-width: 2px 0 0 2px;
  transform: translateX(-50%) rotate(45deg);
}
.dropzone h2 { font-size: 1.15rem; line-height: 1.4; }
.dropzone p { margin-block-start: 4px; }
.dropzone button { margin: 15px auto 12px; }
small { display: block; color: var(--muted); font-size: .875rem; line-height: 1.5; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 8px 24px; border: 0; border-radius: 11px;
  background: var(--accent); color: #171025; font: inherit; font-weight: 700;
  text-decoration: none; text-align: center; cursor: pointer; transition: background-color 180ms;
}
button:hover, .button:hover { background: #ccbfff; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 3px solid #d6cbff; outline-offset: 3px; }
.secondary { background: var(--soft); color: var(--accent); }
.secondary:hover { background: #3b2d57; }
#status { margin-block-start: 12px; padding: 9px 12px; border-radius: 10px; background: var(--soft); }
#status.error { color: #ffc2d7; background: #3b2035; }
.example {
  grid-area: example; align-self: center; min-width: 0;
  padding: clamp(17px, 3vw, 32px);
  border-radius: 28px;
  border: 1px solid #413457;
  background: radial-gradient(ellipse at 75% 0%, #382452, transparent 60%), #1b152c;
}
.example h2 { margin-block-end: 18px; font-size: 1rem; }

.comparison {
  --split: 50%;
  position: relative; isolation: isolate; overflow: hidden;
  border: 1px solid var(--line); border-radius: 17px;
}
.comparison-example { aspect-ratio: 3 / 2; }
.comparison-result { height: clamp(230px, 48vw, 520px); margin-block-start: 17px; }
.comparison-layer { position: absolute; inset: 0; }
.comparison-layer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.comparison-layer.original { background: #261d36; clip-path: inset(0 calc(100% - var(--split)) 0 0); }
.checker { background: repeating-conic-gradient(#302741 0% 25%, #211a30 0% 50%) 0 0 / 20px 20px; }
.comparison-label {
  position: absolute; top: 10px; padding: 5px 9px; border-radius: 7px;
  color: #f6f1ff; background: #1a1327; font-size: .875rem;
}
.label-original { left: 10px; }
.label-preview { right: 10px; }
.comparison-divider {
  position: absolute; z-index: 1; top: 0; bottom: 0; left: var(--split);
  width: 2px; background: #ede6ff; transform: translateX(-50%); pointer-events: none;
  box-shadow: 0 0 12px #160b24;
}
.comparison-divider span {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: grid; grid-template-columns: auto auto; place-content: center; gap: 5px;
  width: 40px; height: 40px; border: 1px solid #f4ecff; border-radius: 50%;
  background: #241638; color: white; box-shadow: 0 3px 12px #100818b0;
}
.comparison-divider span::before, .comparison-divider span::after {
  content: ""; width: 6px; height: 6px; border: solid currentColor;
  border-width: 2px 0 0 2px; transform: rotate(-45deg);
}
.comparison-divider span::after { transform: rotate(135deg); }
.comparison-range {
  position: absolute; z-index: 2; inset: 0; margin: 0; width: 100%; height: 100%;
  opacity: 0; direction: ltr; cursor: ew-resize; touch-action: pan-y;
}
.comparison:focus-within { outline: 3px solid #d6cbff; outline-offset: 3px; }
footer { padding-block: 19px 22px; border-block-start: 1px solid var(--line); font-size: .875rem; color: var(--muted); }
footer span { direction: ltr; display: inline-block; }
footer strong { color: #dfd7f7; }
main:has(#result:not([hidden])) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "intro" "workspace";
  max-width: 980px;
  padding-block-start: clamp(28px, 5vw, 56px);
}
main:has(#result:not([hidden])) .example { display: none; }
main:has(#result:not([hidden])) .intro { margin-block-end: 19px; }
main:has(#result:not([hidden])) h1 { font-size: clamp(1.8rem, 3.4vw, 3rem); }
main:has(#result:not([hidden])) .intro p { display: none; }
#result { padding: clamp(14px, 3vw, 24px); border-radius: 22px; background: #191525; border: 1px solid var(--line); }
.result-title, .apk { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-title h2 { font-size: clamp(1.15rem, 2.4vw, 1.55rem); }
.apk { margin-block-start: 12px; padding: 17px; border: 1px solid #413457; border-radius: 14px; background: var(--soft); }
.apk h3 { font-size: 1.08rem; }
.apk p { margin-block-start: 4px; }
.apk .button { flex-shrink: 0; max-width: 100%; }

.dropzone { position: relative; overflow: hidden; }
.dropzone[aria-busy="true"] {
  border-style: solid;
  border-color: #b5a4ff;
  background: #211a36;
}
.dropzone[aria-busy="true"] .upload-icon {
  background: linear-gradient(145deg, #3b2858, #292043);
}
.dropzone[aria-busy="true"] .upload-icon span { display: none; }
.dropzone[aria-busy="true"] .upload-icon::after {
  content: "";
  grid-area: 1 / 1;
  width: 22px;
  height: 22px;
  border: 2px solid #564574;
  border-block-start-color: var(--accent);
  border-radius: 50%;
  animation: orbit 850ms linear infinite;
}
.dropzone[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #a886ff 45%, #6dd9e8 55%, transparent);
  animation: processing-sweep 1.7s ease-in-out infinite;
  pointer-events: none;
}
.intro { animation: surface-in 400ms ease-out both; }
.example { animation: surface-in 520ms 80ms ease-out both; }
.comparison-example .checker::after {
  content: "";
  position: absolute;
  inset: -40% 0 auto;
  height: 40%;
  opacity: 0;
  background: linear-gradient(180deg, transparent, #7997ff30 96%, #657cdd 100%);
  animation: sample-scan 1.35s 420ms ease-in-out both;
  pointer-events: none;
}
#result:not([hidden]), .apk:not([hidden]) {
  animation: surface-in 300ms ease-out both;
}

@keyframes surface-in {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sample-scan {
  0% { opacity: 0; transform: translateY(0); }
  20%, 80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(350%); }
}
@keyframes processing-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
@keyframes orbit { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .header-inner, main, footer { width: calc(100% - 36px); }
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "intro" "workspace" "example";
    grid-template-rows: auto;
    row-gap: 22px;
    padding-block: 36px 32px;
  }
  .intro, main:has(#result:not([hidden])) .intro { margin-block-end: 0; }
}
@media (max-width: 460px) {
  .header-inner { min-height: 66px; }
  .apk { flex-wrap: wrap; }
  .apk .button { width: 100%; }
  .secondary { padding-inline: 12px; }
  .comparison-label { font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) {
  button, .button, .dropzone { transition: none; }
  .intro, .example, #result:not([hidden]), .apk:not([hidden]),
  .comparison-example .checker::after, .dropzone[aria-busy="true"]::after,
  .dropzone[aria-busy="true"] .upload-icon::after { animation: none; }
}
