:root {
  --bg: #0b0d14;
  --bg-soft: #10131d;
  --card: rgba(22, 26, 40, 0.72);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #eef1f8;
  --muted: #98a0b3;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #06b6d4;
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #06b6d4);
  --danger: #f43f5e;
  --ok: #10b981;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ornamen background */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35; }
.orb-1 { width: 480px; height: 480px; background: #4f46e5; top: -140px; left: -100px; }
.orb-2 { width: 420px; height: 420px; background: #06b6d4; top: 30%; right: -140px; }
.orb-3 { width: 380px; height: 380px; background: #a855f7; bottom: -160px; left: 30%; }

.container { max-width: 760px; margin: 0 auto; padding: 40px 20px 70px; }

/* Header */
.hero { text-align: center; margin-bottom: 30px; }
.logo-badge {
  width: 52px; height: 52px; margin: 0 auto 14px;
  display: grid; place-items: center;
  background: var(--grad); border-radius: 14px;
  color: #fff; box-shadow: 0 8px 28px rgba(99, 102, 241, 0.45);
}
.hero h1 {
  font-size: 2rem; font-weight: 800; letter-spacing: -0.02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { color: var(--muted); font-size: 0.95rem; margin-top: 6px; }
.subtitle code, footer code {
  background: rgba(255, 255, 255, 0.08); padding: 2px 7px; border-radius: 6px; font-size: 0.85em;
}

/* Kartu */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

/* Dropzone */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
  outline: none;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-3);
  background: rgba(6, 182, 212, 0.06);
}
.dropzone:active { transform: scale(0.995); }
.dropzone:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); }
.dz-icon {
  width: 72px; height: 72px; margin: 0 auto 12px;
  display: grid; place-items: center;
  background: rgba(99, 102, 241, 0.12); border-radius: 20px; color: var(--accent-3);
}
.dz-title { font-size: 1.02rem; }
.muted { color: var(--muted); font-size: 0.85rem; }

.dz-preview { position: relative; display: none; }
.dz-preview:not([hidden]) { display: inline-block; }
.dz-preview img {
  max-width: 100%; max-height: 340px;
  border-radius: 12px; border: 1px solid var(--card-border);
  background: rgba(0,0,0,0.25); display: block;
}
#resultImage img {
  max-width: 100%; max-height: 420px;
  border-radius: 12px; border: 1px solid var(--card-border);
  cursor: zoom-in;
}
.btn-remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 1.05rem; line-height: 1;
  cursor: pointer; transition: background .2s;
}
.btn-remove:hover { background: var(--danger); }
.file-meta { margin-top: 10px; color: var(--muted); font-size: 0.8rem; }

/* Form */
label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 8px; color: #c7cddd; }
.required { color: var(--danger); }
.prompt-wrap { position: relative; }
textarea {
  width: 100%; padding: 14px; margin-bottom: 16px;
  background: rgba(10, 12, 20, 0.65); color: var(--text);
  border: 1px solid var(--card-border); border-radius: 12px;
  font-family: inherit; font-size: 0.95rem; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.hint { font-size: 0.78rem; color: var(--muted); margin: -8px 0 12px; }
.hidden { display: none; }

.row { display: flex; gap: 16px; margin-bottom: 18px; }
.field { flex: 1; }
.select-wrap { position: relative; }
select {
  width: 100%; padding: 12px 36px 12px 14px;
  background: rgba(10, 12, 20, 0.65); color: var(--text);
  border: 1px solid var(--card-border); border-radius: 12px;
  font-size: 0.9rem; font-family: inherit;
  appearance: none; -webkit-appearance: none; cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }
.chevron { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input[type="range"] {
  width: 100%; margin-top: 10px;
  accent-color: var(--accent); cursor: pointer;
}

.btn-primary {
  width: 100%; padding: 15px;
  background: var(--grad); color: #fff;
  border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: opacity .2s, transform .2s, box-shadow .2s;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(99, 102, 241, 0.45); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hasil */
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.result-head h2 { font-size: 1.12rem; font-weight: 700; }
.badge {
  font-size: 0.72rem; font-weight: 600; padding: 4px 10px;
  background: rgba(16, 185, 129, 0.12); color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.3); border-radius: 999px;
}
.compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px;
}
.compare-item { text-align: center; }
.compare-item figcaption {
  font-size: 0.78rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px;
}
.compare-item img {
  width: 100%; max-height: 380px; object-fit: contain;
  border-radius: 12px; border: 1px solid var(--card-border); background: rgba(0,0,0,0.25);
}
.result-text {
  line-height: 1.65; font-size: 0.94rem;
  white-space: pre-wrap; word-wrap: break-word;
  background: rgba(10, 12, 20, 0.5); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 14px; margin-bottom: 16px;
}

/* Download */
.download-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
  background: rgba(10, 12, 20, 0.5); border: 1px solid var(--card-border); border-radius: 12px;
}
.download-title { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-right: 2px; }
.btn-download {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.07); color: var(--text);
  border: 1px solid var(--card-border);
  font-size: 0.85rem; font-weight: 700; text-decoration: none;
  transition: background .2s, border-color .2s, transform .2s;
}
.btn-download:hover { background: rgba(99, 102, 241, 0.18); border-color: var(--accent); transform: translateY(-1px); }
.btn-download:active { transform: translateY(0); }

.raw-toggle { margin-top: 4px; }
summary { cursor: pointer; color: var(--muted); font-size: 0.82rem; font-weight: 500; }
summary:hover { color: var(--text); }
pre {
  margin-top: 10px; padding: 13px;
  background: rgba(10, 12, 20, 0.8); border: 1px solid var(--card-border); border-radius: 10px;
  font-size: 0.74rem; overflow-x: auto; max-height: 280px; overflow-y: auto; color: #c7cddd;
}

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: rgba(244, 63, 94, 0.95); color: #fff;
  padding: 13px 22px; border-radius: 12px; font-size: 0.9rem; font-weight: 500;
  max-width: 92%; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 99; backdrop-filter: blur(8px);
}

footer { text-align: center; margin-top: 26px; }

/* Lightbox full-preview */
.lightbox {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(5, 7, 12, 0.94);
  align-items: center; justify-content: center;
  cursor: zoom-out; padding: 24px;
  backdrop-filter: blur(6px);
}
.lightbox:not([hidden]) { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: 12px; object-fit: contain;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7);
}
.lightbox-close {
  position: absolute; top: 18px; right: 18px;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 1.15rem; cursor: pointer;
  transition: background .2s, transform .2s;
}
.lightbox-close:hover { background: rgba(244, 63, 94, 0.7); transform: scale(1.05); }
.lightbox-download {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 10px;
  background: var(--grad); color: #fff;
  text-decoration: none; font-weight: 700; font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  transition: transform .2s;
}
.lightbox-download:hover { transform: translateX(-50%) translateY(-1px); }

@media (max-width: 600px) {
  .container { padding: 26px 16px 50px; }
  .row { flex-direction: column; gap: 12px; }
  .compare { grid-template-columns: 1fr; }
}
