:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text-dark: #1e293b;
  --text-heading: #0f172a;
  --text-light: #475569;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --ok: #15803d;
  --bad: #b91c1c;
  --shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  background: var(--bg-body);
  color: var(--text-dark);
  line-height: 1.6;
}

img { max-width: 100%; }

button,
input,
select,
textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: var(--primary); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.hidden { display: none !important; }

.site-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-inner {
  width: min(1152px, 100%);
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  color: var(--primary);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
  line-height: 1;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links > a,
.nav-drop-btn {
  text-decoration: none;
  color: var(--text-dark);
  font-weight: 600;
  padding: 8px 12px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: none;
  border: 0;
}

.nav-links > a:hover,
.nav-drop-btn:hover { background: #f1f5f9; }

.nav-drop { position: relative; }

.nav-drop::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 14px;
}

.nav-drop-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 240px;
  padding: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

.nav-drop:hover .nav-drop-menu,
.nav-drop:focus-within .nav-drop-menu,
.nav-drop.open .nav-drop-menu { display: block; }

.nav-drop-menu a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-dark);
  font-weight: 600;
  font-size: 14px;
}

.nav-drop-menu a:hover,
.nav-drop-menu a[aria-current="page"] {
  background: #eff6ff;
  color: var(--primary);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 80;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus { top: 8px; }

.menu-btn {
  display: none;
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--text-dark);
  border-radius: 10px;
  place-items: center;
  cursor: pointer;
  position: relative;
  z-index: 60;
}

.menu-btn svg { pointer-events: none; }

main {
  width: min(896px, calc(100% - 32px));
  margin: 48px auto 32px;
}

h1 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-heading);
}

.subtitle {
  margin: 0 auto 32px;
  max-width: 680px;
  color: var(--text-light);
  font-size: 16px;
}

.text-center { text-align: center; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
}

#image-tool { min-height: 360px; }

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  text-align: center;
  padding: 48px 20px;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.dz-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  color: var(--primary);
}

.dropzone h3,
.dropzone .drop-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-heading);
}

.dropzone p { margin: 0 0 16px; color: var(--text-light); }

.btn-browse,
.btn-action,
.btn-secondary {
  border: 0;
  font-weight: 700;
}

.btn-browse {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 12px 28px;
  min-height: 48px;
  font-size: 16px;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.25);
}

.btn-action {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 18px;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-browse:hover,
.btn-action:hover { background: var(--primary-hover); }

.btn-action:disabled,
.btn-browse:disabled,
.btn-secondary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-secondary {
  background: #fff;
  color: var(--text-dark);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
}

.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.trust {
  margin: 10px 0 0;
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  flex: none;
}

.preview-meta { min-width: 0; }
.preview-meta strong,
.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-meta span,
.file-sub { color: var(--text-light); font-size: 14px; }

.btn-change {
  margin-left: auto;
  background: #eff6ff;
  color: var(--primary);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  flex: none;
}

.settings-grid {
  display: grid;
  gap: 22px;
}

.step-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-heading);
}

.step-title span { color: var(--primary); margin-right: 6px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field { margin-bottom: 12px; }

.field label,
.check {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
}

input[type="number"],
input[type="text"],
input[type="email"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
}

textarea { min-height: 140px; resize: vertical; }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input[type="range"] { width: 100%; accent-color: var(--primary); }

.hint { margin: 6px 0 0; color: var(--text-light); font-size: 13px; }

.kb-lock {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: var(--ok);
  font-weight: 800;
  border-radius: 10px;
  padding: 12px 14px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-dark);
}

.chip:hover,
.chip.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.stat {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.stat span {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  color: var(--text-heading);
}

.stat strong.ok { color: var(--ok); }
.stat strong.bad { color: var(--bad); }

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.compare figure {
  margin: 0;
  text-align: center;
}

.compare img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.compare figcaption {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
}

.status {
  min-height: 1.25em;
  margin: 10px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
}

.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.section {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 64px;
  content-visibility: auto;
  contain-intrinsic-size: auto 520px;
}

.site-footer {
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head h2,
.section h2 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-heading);
}

.section-lead {
  text-align: center;
  color: var(--text-light);
  margin: 0 auto 24px;
  max-width: 640px;
}

.badge {
  display: inline-flex;
  align-items: center;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.tools-grid,
.features-grid,
.seo-grid,
.steps {
  display: grid;
  gap: 16px;
}

.tool-card,
.feature-card,
.seo-card,
.step-card,
.prose {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
}

.tool-card {
  display: block;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.tool-icon,
.feature-icon,
.seo-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #eff6ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.tool-card h3,
.feature-card h3,
.seo-card h2,
.step-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-heading);
}

.seo-card h2 { font-size: 22px; letter-spacing: -0.03em; }

.tool-card p,
.feature-card p,
.seo-card p,
.step-card p { margin: 0; color: var(--text-light); font-size: 14px; }

.seo-card p { font-size: 15px; }

.seo-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.seo-top h2 { margin: 0; }

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  margin-bottom: 8px;
}

.features-grid { margin-top: 28px; gap: 20px; }
.seo-grid { gap: 20px; }

.faq details {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
}

.faq summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-heading);
  list-style: none;
}

.faq summary::-webkit-details-marker { display: none; }

.faq .chev {
  flex: none;
  color: var(--text-light);
  transition: transform 0.2s ease;
}

.faq details[open] .chev { transform: rotate(180deg); }

.faq details p { margin: 12px 0 0; color: #475569; }

.prose { padding: 28px; }
.prose h2 { text-align: left; font-size: 20px; margin: 24px 0 8px; }
.prose p,
.prose li { color: #475569; }
.prose ul { padding-left: 18px; }

.stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
}

.stage canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(540px, 70vh);
}

.crop-box {
  position: absolute;
  border: 2px solid var(--primary);
  box-sizing: border-box;
  touch-action: none;
  cursor: move;
}

.crop-box.idle {
  border-style: dashed;
  background: rgba(37, 99, 235, 0.08);
}

.crop-box .handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 50%;
}

.crop-box .handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-box .handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-box .handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-box .handle.se { bottom: -8px; right: -8px; cursor: nwse-resize; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.thumbs button {
  width: 108px;
  border: 2px solid transparent;
  padding: 4px;
  border-radius: 10px;
  background: #fff;
}

.thumbs button.active { border-color: var(--primary); }

.thumbs canvas {
  width: 100%;
  height: 78px;
  background: #f8fafc;
  border-radius: 6px;
}

.thumbs span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding-top: 4px;
}

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.action-row .btn-action { width: auto; flex: 1 1 240px; }

.page-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  padding: 64px 20px;
  text-align: center;
}

.site-footer h3 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 20px;
}

.site-footer p { margin: 0 auto; max-width: 560px; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  justify-content: center;
  margin: 18px 0;
}

.footer-links a {
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 700;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.footer-links a:hover { color: #fff; }

.copy { margin-top: 8px; font-size: 14px; }

@media (min-width: 720px) {
  h1 { font-size: 40px; }
  .settings-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .features-grid,
  .seo-grid,
  .steps { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 980px) {
  .tools-grid,
  .features-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 719px) {
  .fields,
  .stats,
  .compare { grid-template-columns: 1fr; }
  .menu-btn { display: grid; }
  .site-nav { position: sticky; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px 16px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  }
  .nav-links.open {
    display: flex;
    z-index: 50;
  }
  .nav-drop-menu {
    position: static;
    display: none;
    box-shadow: none;
    border: 0;
    padding: 0 0 0 8px;
    min-width: 0;
  }
  .nav-drop::before { display: none; }
  .nav-links.open .nav-drop-menu,
  .nav-drop.open .nav-drop-menu { display: block; }
  .nav-links.open .nav-drop-btn { pointer-events: none; }
  .nav-links a { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tool-card,
  .faq .chev { transition: none; }
}

body.has-file .nav-inner { padding: 4px 12px; }
body.has-file .logo { font-size: 18px; }
body.has-file .menu-btn { width: 32px; height: 32px; }
body.has-file main { margin: 6px auto 16px; }
body.has-file main > .text-center:first-child { display: none; }
body.has-file .card { padding: 8px 10px 8px; }
body.has-file .preview-bar {
  gap: 8px;
  padding-bottom: 6px;
  margin-bottom: 6px;
}
body.has-file .thumb { width: 32px; height: 32px; border-radius: 8px; }
body.has-file .preview-meta { flex: 1; min-width: 0; }
body.has-file .preview-meta strong,
body.has-file .preview-meta span,
body.has-file .file-sub {
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.has-file .btn-change { padding: 4px 8px; font-size: 12px; }
body.has-file .step-title,
body.has-file .hint,
body.has-file .trust { display: none; }
body.has-file .chips { gap: 4px; margin-bottom: 6px; }
body.has-file .chip { padding: 3px 7px; font-size: 12px; }
body.has-file .fields { grid-template-columns: 1fr 1fr; gap: 6px; }
body.has-file .settings-grid {
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin-top: 0;
}
body.has-file .settings-grid > div:has(#quality-field) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 8px;
  align-content: start;
}
body.has-file .settings-grid > div:has(#quality-field) > .field:first-of-type { grid-column: 1 / -1; }
body.has-file .field { margin-bottom: 4px; }
body.has-file .field label,
body.has-file .check { font-size: 12px; margin-bottom: 2px; line-height: 1.2; }
body.has-file input[type="number"],
body.has-file input[type="text"],
body.has-file select {
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 14px;
}
body.has-file input[type="range"] { height: 18px; margin: 0; }
body.has-file .kb-lock { padding: 5px 8px; font-size: 13px; }
body.has-file .btn-action { padding: 8px 10px; font-size: 15px; }
body.has-file .btn-secondary { padding: 8px 8px; font-size: 13px; }
body.has-file .action-row { margin-top: 6px; flex-wrap: nowrap; }
body.has-file .action-row .btn-action,
body.has-file .action-row .btn-secondary { width: auto; flex: 1 1 0; min-width: 0; }
body.has-file .stats { margin: 8px 0; gap: 6px; }
body.has-file .stat { padding: 6px 4px; }
body.has-file .stat strong { font-size: 15px; }
body.has-file .editor-split {
  display: flex;
  flex-direction: column;
}
body.has-file .editor-split > .tool-options { order: 1; }
body.has-file .editor-preview { order: 2; min-width: 0; }
body.has-file .live-shot { margin: 8px 0 0; }
body.has-file .live-shot {
  display: flex;
  flex-direction: column;
  align-items: center;
}
body.has-file .live-shot img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(220px, 32svh);
  object-fit: contain;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}
body.has-file .live-shot figcaption {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  text-align: center;
}
body.has-file .editor-preview .stats { margin-top: 8px; }
body.has-file .status { margin-top: 4px; font-size: 12px; min-height: 0; }
body.has-file .status:empty { display: none; }
body.has-file .page-row { margin: 0 0 8px; }
body.has-file .tool-options { flex: none; }
body.has-file .workspace {
  max-height: calc(100vh - 52px);
  max-height: calc(100svh - 52px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.has-file .tool-preview {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
body.has-file .tool-preview .stage {
  max-width: 100%;
  max-height: 100%;
}
body.has-file .tool-preview .stage canvas {
  max-height: min(360px, 32svh);
  max-width: 100%;
}
body.has-file .thumbs {
  flex: none;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  margin-top: 0;
}
body.has-file .thumbs button { width: 72px; flex: none; }
body.has-file .thumbs canvas { height: 46px; }

@media (min-width: 900px) {
  body.has-file main { width: min(1160px, calc(100% - 48px)); }
  body.has-file .editor-split,
  body.has-file .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.85fr);
    gap: 18px;
    align-items: start;
    max-height: none;
    overflow: visible;
  }
  body.has-file .editor-preview,
  body.has-file .workspace .tool-preview {
    grid-column: 1;
    grid-row: 1;
  }
  body.has-file .editor-split > .tool-options,
  body.has-file .workspace > .tool-options {
    grid-column: 2;
    grid-row: 1;
  }
  body.has-file .live-shot { margin: 0; }
  body.has-file .live-shot img {
    max-height: min(640px, 70vh);
  }
  body.has-file .tool-preview .stage canvas {
    max-height: min(760px, 74vh);
  }
  body.has-file .editor-split.no-preview {
    display: block;
  }
}
