:root {
  color-scheme: light;
  --bg: #f4f7ff;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --text: #172033;
  --muted: #64708a;
  --line: #dfe5f2;
  --line-strong: #c9d3e7;
  --primary: #5b5bd6;
  --primary-dark: #4646ba;
  --primary-soft: #eeeeff;
  --success: #137a5a;
  --success-soft: #e9f8f2;
  --error: #b42318;
  --error-soft: #fff0ee;
  --shadow: 0 24px 70px rgba(42, 55, 91, 0.12);
  --shadow-soft: 0 12px 35px rgba(42, 55, 91, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 0%, rgba(129, 140, 248, 0.18), transparent 32rem),
    radial-gradient(circle at 92% 18%, rgba(56, 189, 248, 0.13), transparent 28rem),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
  image-orientation: from-image;
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid rgba(201, 211, 231, 0.72);
  background: rgba(244, 247, 255, 0.78);
  backdrop-filter: blur(16px);
}

.header-inner,
.footer-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-weight: 760;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  box-shadow: 0 8px 18px rgba(91, 91, 214, 0.25);
}

.brand-mark svg,
.upload-icon svg,
.privacy-icon svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg {
  color: #fff;
}

.header-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero {
  padding: 30px 0 38px;
  text-align: center;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin: 0 auto 16px;
  font-size: clamp(2.55rem, 6vw, 4.9rem);
  line-height: 1.02;
  letter-spacing: -0.058em;
}

.hero-copy {
  max-width: 690px;
  margin: 0 auto;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.22rem);
}

.converter-section {
  padding-bottom: 68px;
}

.converter-card,
.result-panel {
  overflow: hidden;
  border: 1px solid rgba(201, 211, 231, 0.82);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.converter-main {
  padding: 34px;
}

.drop-zone {
  min-height: 285px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 36px;
  border: 2px dashed #bfc9df;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(238, 238, 255, 0.6), rgba(245, 250, 255, 0.78));
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: none;
  transform: translateY(-2px);
}

.upload-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 18px;
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 12px 28px rgba(67, 76, 126, 0.12);
}

.upload-icon svg {
  width: 28px;
}

.drop-zone strong {
  font-size: 1.13rem;
}

.drop-zone > span {
  color: var(--muted);
}

.drop-zone small {
  margin-top: 8px;
  color: #7a849b;
}

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

.selected-file {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.file-thumb-wrap {
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 12px;
  background: #e9edf5;
}

.file-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-summary {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.file-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-summary span {
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-button,
.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  padding: 9px 13px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.55fr);
  gap: 18px;
  margin-top: 22px;
}

.target-control {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 13px 10px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 650;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.input-wrap input {
  width: 104px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 760;
  text-align: right;
  padding: 0 12px;
  outline: none;
}

.input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(91, 91, 214, 0.12);
}

.primary-button,
.secondary-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 22px;
  border-radius: 14px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--primary), #7373e8);
  color: #fff;
  box-shadow: 0 12px 25px rgba(91, 91, 214, 0.24);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover:not(:disabled) {
  box-shadow: 0 16px 30px rgba(91, 91, 214, 0.3);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

.button-arrow {
  font-size: 1.35rem;
  line-height: 1;
}

.message {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.93rem;
}

.message.is-error {
  background: var(--error-soft);
  color: var(--error);
}

.message.is-progress {
  background: var(--primary-soft);
  color: #4c4ca8;
}

.message.is-success {
  background: var(--success-soft);
  color: var(--success);
}

.privacy-panel {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 20px 34px;
  border-top: 1px solid var(--line);
  background: #fbfcff;
}

.privacy-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--success-soft);
  color: var(--success);
}

.privacy-panel strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.93rem;
}

.privacy-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.result-panel {
  margin-top: 28px;
  padding: 32px;
  box-shadow: var(--shadow-soft);
}

.result-heading,
.result-summary,
.preview-label,
.image-meta,
.result-actions {
  display: flex;
  align-items: center;
}

.result-heading,
.result-summary {
  justify-content: space-between;
  gap: 24px;
}

.result-kicker,
.section-heading > span {
  display: block;
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.result-heading h2,
.section-heading h2 {
  margin-bottom: 0;
  letter-spacing: -0.035em;
}

.target-badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.86rem;
  font-weight: 760;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 26px;
}

.preview-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.result-card {
  border-color: rgba(91, 91, 214, 0.35);
  box-shadow: inset 0 0 0 1px rgba(91, 91, 214, 0.06);
}

.preview-label {
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 760;
}

.preview-label span:last-child {
  color: var(--primary);
}

.image-stage {
  min-height: 340px;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #eef2f8;
}

.image-stage img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 7px;
  box-shadow: 0 10px 28px rgba(24, 34, 58, 0.17);
}

.checkerboard {
  background-color: #edf1f8;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.6) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.6) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.6) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.6) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.image-meta {
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 14px 16px;
}

.image-meta div {
  min-width: 0;
}

.image-meta dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.image-meta dd {
  margin: 1px 0 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.result-summary {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.saving-summary {
  display: flex;
  flex-direction: column;
  color: var(--muted);
  font-size: 0.86rem;
}

.saving-summary strong {
  color: var(--success);
  font-size: 1.5rem;
  line-height: 1.2;
}

.result-actions {
  gap: 12px;
}

.secondary-button {
  background: var(--surface);
}

.download-button {
  min-width: 184px;
}

.info-section,
.faq-section {
  padding: 58px 0;
}

.section-heading {
  max-width: 650px;
  margin-bottom: 28px;
}

.section-heading h2 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.12;
}

.section-heading.compact h2 {
  font-size: clamp(1.75rem, 3vw, 2.45rem);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.steps-grid article {
  min-height: 220px;
  padding: 26px;
  border: 1px solid rgba(201, 211, 231, 0.86);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 36px rgba(53, 64, 103, 0.06);
}

.steps-grid article > span {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
}

.steps-grid h3 {
  margin-bottom: 7px;
  font-size: 1.05rem;
}

.steps-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.faq-section {
  padding-top: 28px;
  padding-bottom: 90px;
}

.faq-list {
  border-top: 1px solid var(--line-strong);
}

.faq-list details {
  border-bottom: 1px solid var(--line-strong);
}

.faq-list summary {
  position: relative;
  padding: 21px 44px 21px 0;
  cursor: pointer;
  font-weight: 730;
  list-style: none;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  position: absolute;
  right: 8px;
  top: 18px;
  color: var(--primary);
  font-size: 1.35rem;
  font-weight: 400;
}

.faq-list details[open] summary::after {
  content: "−";
}

.faq-list p {
  max-width: 760px;
  padding: 0 0 21px;
  margin-bottom: 0;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  font-size: 0.86rem;
}

.footer-inner {
  justify-content: flex-start;
  gap: 18px;
}

.footer-inner a {
  color: var(--primary-dark);
  font-weight: 650;
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(91, 91, 214, 0.25);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.is-processing .button-arrow {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  font-size: 0;
  animation: spin 750ms linear infinite;
}

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

@media (max-width: 780px) {
  .shell {
    width: min(100% - 28px, 1120px);
  }

  .header-note {
    display: none;
  }

  .hero {
    padding-top: 30px;
  }

  .converter-main,
  .result-panel {
    padding: 22px;
  }

  .privacy-panel {
    padding: 18px 22px;
  }

  .drop-zone {
    min-height: 235px;
    padding: 28px 20px;
  }

  .control-row,
  .comparison-grid,
  .steps-grid {
    grid-template-columns: 1fr;
  }

  .image-stage {
    min-height: 280px;
  }

  .result-heading,
  .result-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-actions {
    width: 100%;
    flex-direction: column-reverse;
  }

  .result-actions > * {
    width: 100%;
  }

  .steps-grid article {
    min-height: 0;
  }
}

@media (max-width: 480px) {
  .header-inner,
  .footer-inner {
    min-height: 64px;
  }

  .brand {
    font-size: 0.92rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  h1 {
    font-size: 2.55rem;
  }

  .converter-section {
    width: 100%;
  }

  .converter-card,
  .result-panel {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .selected-file {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .file-thumb-wrap {
    width: 54px;
    height: 54px;
  }

  .selected-file .icon-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .target-control {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .input-wrap,
  .input-wrap input {
    width: 100%;
  }

  .input-wrap input {
    text-align: left;
  }

  .image-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
