/* w2png — clean, minimal styling */

:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e6e8ef;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --ok: #16a34a;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(31, 36, 48, .08);
}

* { box-sizing: border-box; }

/* The JS toggles the [hidden] attribute to show/hide #status, #result and
   #error. Class rules below set display:flex/grid on those elements, which would
   otherwise win over the browser's [hidden]{display:none} — so make hidden win. */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: var(--accent); color: #fff;
  border-radius: 9px; font-weight: 800; font-size: 18px;
}
.brand-text { font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.site-nav { display: flex; gap: 18px; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.site-nav a:hover, .site-nav a.is-active { color: var(--accent); }

/* ---------- layout ---------- */
.container {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 20px 40px;
}

.hero { text-align: center; margin: 18px 0 26px; }
.hero h1 { font-size: clamp(28px, 6vw, 40px); margin: 0 0 8px; letter-spacing: -.03em; }
.lead { color: var(--muted); font-size: 17px; margin: 0; }

/* ---------- card / form ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }

.url-row { display: flex; gap: 10px; }
#url {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfbfe;
  transition: border-color .15s, box-shadow .15s;
}
#url:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
  background: #fff;
}

.go-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 11px;
  padding: 0 22px; font-size: 16px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .05s;
}
.go-btn:hover { background: var(--accent-dark); }
.go-btn:active { transform: translateY(1px); }
.go-btn:disabled { opacity: .6; cursor: progress; }
.go-arrow { font-size: 22px; line-height: 1; }

/* ---------- format chips ---------- */
.formats {
  border: none; padding: 0; margin: 18px 0 0;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.formats legend { float: left; width: 100%; font-size: 14px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-block;
  padding: 9px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600; font-size: 14px;
  background: #fbfbfe; color: var(--muted);
  transition: all .15s;
}
.chip input:checked + span {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(79, 70, 229, .25); }

/* ---------- status / error ---------- */
.status {
  display: flex; align-items: center; gap: 12px;
  margin-top: 20px; color: var(--muted); font-size: 15px;
}
.spinner {
  width: 20px; height: 20px; flex: none;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  margin-top: 20px; padding: 13px 16px;
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  border-radius: 11px; font-size: 15px;
}

/* ---------- result ---------- */
.result {
  margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: start;
}
.result-preview a { display: block; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fbfbfe; }
.result-preview img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover; object-position: top; }
.preview-pdf { display: grid; place-items: center; height: 120px; font-weight: 700; color: var(--accent); }
.result-name { font-weight: 700; margin: 0 0 2px; word-break: break-all; }
.result-sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.download-btn {
  display: inline-block;
  background: var(--ok); color: #fff; text-decoration: none;
  padding: 12px 22px; border-radius: 11px; font-weight: 700;
}
.download-btn:hover { filter: brightness(.95); }
.view-btn {
  display: inline-block;
  background: var(--accent); color: #fff;
  border: none; padding: 12px 22px; border-radius: 11px;
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.view-btn:hover { background: var(--accent-dark); }
.link-btn {
  display: inline-block; margin-top: 12px;
  background: none; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; text-decoration: underline; padding: 0;
}

/* ---------- online viewer (modal) ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(17, 20, 28, .82);
  display: flex; flex-direction: column;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.viewer-bar {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 18px; color: #fff;
}
.viewer-name { font-size: 14px; opacity: .9; word-break: break-all; }
.viewer-close {
  flex: none; width: 40px; height: 40px; line-height: 1;
  border: none; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .15); color: #fff; font-size: 26px;
}
.viewer-close:hover { background: rgba(255, 255, 255, .28); }
.viewer-body {
  flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 0 16px 24px; text-align: center;
}
.viewer-body img {
  display: block; width: min(900px, 100%); height: auto;
  margin: 0 auto; background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.viewer-body iframe {
  display: block; width: min(900px, 100%); height: 100%;
  min-height: 80vh; margin: 0 auto; border: 0; background: #fff;
}
body.viewer-open { overflow: hidden; }

/* ---------- how it works ---------- */
.how { margin-top: 34px; }
.how h2 { font-size: 18px; margin: 0 0 10px; }
.how ol { margin: 0; padding-left: 20px; color: var(--muted); }
.how li { margin: 4px 0; }

/* ---------- house ad (SuperDMZ promo, colour-cycling) ---------- */
.ad-slot { position: relative; margin: 22px 0; }
.ad-tag {
  position: absolute; top: 9px; right: 13px; z-index: 2;
  font-size: 10px; text-transform: uppercase; letter-spacing: .14em;
  color: rgba(234, 240, 255, .45); pointer-events: none;
}

/* Animatable accent colour — registered so it can interpolate inside @keyframes.
   Browsers without @property keep the static --p-acc on .promo (just no animation). */
@property --p-acc {
  syntax: "<color>";
  inherits: true;
  initial-value: #3dd7c0;
}
@keyframes promo-hue {              /* 3 colours, ~5s each → 15s loop */
  0%,   26.6%  { --p-acc: #3dd7c0; }   /* teal   */
  33.3%, 60%   { --p-acc: #a78bfa; }   /* violet */
  66.6%, 93.3% { --p-acc: #fbbf24; }   /* amber  */
  100%         { --p-acc: #3dd7c0; }
}

.promo {
  --p-acc: #3dd7c0;
  animation: promo-hue 15s linear infinite;
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 20px;
  padding: 18px 22px;
  text-decoration: none; color: #eaf0ff;
  border: 1px solid #2b3a63; border-radius: var(--radius);
  background: radial-gradient(135% 150% at 0% 0%, #1c2747 0%, #131a2e 55%, #0d1320 100%);
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.promo--alt { animation-delay: -7.5s; }   /* bottom banner runs out of phase */

.promo::after {
  content: ""; position: absolute; right: -50px; top: -70px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(61, 215, 192, .20), transparent 70%);
  background: radial-gradient(circle, color-mix(in srgb, var(--p-acc) 24%, transparent), transparent 70%);
  pointer-events: none;
}
.promo:hover {
  transform: translateY(-2px); border-color: var(--p-acc);
  box-shadow: 0 16px 38px rgba(8, 12, 22, .42);
}

.promo-logo { flex: none; display: flex; align-items: center; gap: 8px; color: var(--p-acc); }
.promo-logo svg { display: block; }
.promo-logo-text { font-weight: 800; font-size: 15px; letter-spacing: -.01em; color: #eaf0ff; }

.promo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.promo-title { font-size: 17px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
.promo-sub { font-size: 13.5px; line-height: 1.4; color: #aab6d6; }

.promo-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.promo-chips span {
  font-size: 11px; font-weight: 600; color: #d3ddf6;
  background: rgba(61, 215, 192, .12);
  background: color-mix(in srgb, var(--p-acc) 13%, transparent);
  border: 1px solid rgba(61, 215, 192, .30);
  border-color: color-mix(in srgb, var(--p-acc) 32%, transparent);
  padding: 2px 9px; border-radius: 999px;
}

.promo-cta {
  flex: none; white-space: nowrap;
  font-weight: 700; font-size: 14px; color: #0c1322;
  background: #3dd7c0; background: var(--p-acc);
  padding: 11px 17px; border-radius: 10px;
  box-shadow: 0 6px 16px rgba(61, 215, 192, .28);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--p-acc) 45%, transparent);
}
.promo:hover .promo-cta {
  background: #57e8d1;
  background: color-mix(in srgb, var(--p-acc) 82%, #fff);
}

@media (max-width: 620px) {
  .promo { flex-direction: column; align-items: flex-start; gap: 13px; }
  .promo-cta { align-self: stretch; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .promo { animation: none; }
}

/* ---------- footer ---------- */
.site-footer {
  text-align: center; color: var(--muted);
  font-size: 13px; padding: 26px 20px 34px;
  border-top: 1px solid var(--line); margin-top: 30px;
}
.site-footer p { margin: 4px 0; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* ---------- legal pages ---------- */
.legal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.legal h1 { margin-top: 0; }
.legal h2 { font-size: 18px; margin-top: 26px; }
.legal p, .legal li { color: #3b4252; }
.legal .updated { color: var(--muted); font-size: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .result { grid-template-columns: 1fr; }
  .go-btn { padding: 0 18px; }
  #url { padding: 12px 14px; }
  .link-btn { display: block; margin: 12px 0 0; }
}

/* ---------- image tool (client-side) ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; cursor: pointer;
  padding: 30px 20px; margin-bottom: 16px;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: #fafbff; color: var(--muted);
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: #f5f6ff; outline: none; }
.dropzone.is-drag { border-color: var(--accent); background: #eef0ff; color: var(--accent-dark); }
.dz-icon { font-size: 30px; line-height: 1; }
.dz-text { font-size: 15px; color: var(--ink); }
.dz-text strong { color: var(--accent); }
.dz-sub { font-size: 12.5px; }

.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0 4px; }
.opt-grid.no-quality { grid-template-columns: 1fr; }
.opt-grid .opt { min-width: 0; }
.opt input[type=range] { width: 100%; accent-color: var(--accent); }
.num-row { display: flex; align-items: center; gap: 8px; }
.num {
  width: 120px; padding: 9px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.num:focus { outline: none; border-color: var(--accent); }
.num-unit { color: var(--muted); font-size: 14px; }

.tool-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 0 4px; }

.results { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.rcard {
  display: flex; align-items: center; gap: 14px;
  padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.rthumb {
  width: 56px; height: 56px; flex: none; object-fit: cover; border-radius: 8px;
  background: repeating-conic-gradient(#eef0f6 0% 25%, #fff 0% 50%) 50% / 14px 14px;
}
.rinfo { flex: 1; min-width: 0; }
.rname { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmeta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.rsave { font-weight: 700; }
.rsave.good { color: var(--ok); }
.rsave.bad  { color: var(--danger); }
.rsave.busy { color: var(--muted); font-weight: 500; }
.rdl {
  flex: none; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 20px; font-weight: 700;
}
.rdl:hover { background: var(--accent-dark); }
.rcard.error .rmeta { color: var(--danger); }
.rcard.error .rdl { display: none; }

@media (max-width: 560px) {
  .opt-grid { grid-template-columns: 1fr; }
}

/* ---------- header: brand left, nav + language switch right ---------- */
.site-header { flex-wrap: wrap; gap: 8px 16px; }
.brand { margin-right: auto; }
.lang-switch { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lang-switch a {
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--muted); text-decoration: none;
  padding: 3px 7px; border-radius: 7px;
}
.lang-switch a:hover { color: var(--accent); background: #eef0ff; }
.lang-switch a.is-active { color: #fff; background: var(--accent); }

/* ---------- use cases ---------- */
.uses { margin-top: 30px; }
.uses h2 { font-size: 18px; margin: 0 0 10px; }
.uses ul { margin: 0; padding-left: 20px; color: var(--muted); }
.uses li { margin: 5px 0; }

/* ---------- FAQ (accordion) ---------- */
.faq { margin-top: 36px; }
.faq h2 { font-size: 18px; margin: 0 0 12px; }
.faq-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; margin-bottom: 10px; padding: 0 16px;
}
.faq-item summary {
  cursor: pointer; font-weight: 600; padding: 14px 26px 14px 0;
  list-style: none; position: relative;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; position: absolute; right: 2px; top: 11px;
  font-size: 22px; line-height: 1; color: var(--accent); font-weight: 400;
}
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p { margin: 0 0 14px; color: #3b4252; }

/* ---------- Text -> QR Code tool ---------- */
.qr-text {
  width: 100%; font-size: 15px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 11px; background: #fbfbfe;
  color: var(--ink); resize: vertical; font-family: inherit; min-height: 70px;
}
.qr-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.15); background: #fff; }
.qr-opts { display: flex; gap: 22px; flex-wrap: wrap; margin: 16px 0 2px; }
.qr-opt { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.qr-opt input[type=range] { accent-color: var(--accent); min-width: 180px; }
.qr-opt select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); font-size: 14px; }
.qr-output { margin-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.qr-canvas-wrap { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
#qr-canvas { display: block; width: auto; max-width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.qr-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.qr-svg-btn { text-decoration: none; }
