:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #181a1f;
  --surface-2: #202329;
  --border: #30343c;
  --muted: #9ba1ad;
  --text: #f5f7fa;
  --accent: #d6ff45;
  --accent-dark: #182000;
  --danger: #ff6b6b;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar { height: 72px; padding: 0 clamp(22px, 5vw, 72px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 11px; font-size: 24px; font-weight: 800; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: var(--accent); border: 1px solid #4c5730; border-radius: 10px; }
.brand-mark svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #d6ff4517; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.workspace { margin: 58px 0; }
.drop-zone { min-height: 360px; border: 1px dashed #555c68; background: linear-gradient(145deg, #191b20, #15171b); border-radius: 22px; display: flex; flex-direction: column; justify-content: center; align-items: center; cursor: pointer; transition: .2s ease; outline: none; }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragover { border-color: var(--accent); background: #d6ff4508; transform: translateY(-2px); }
.upload-icon { width: 70px; height: 70px; border-radius: 19px; display: grid; place-items: center; color: var(--accent); background: #d6ff4510; border: 1px solid #d6ff4526; }
.upload-icon svg { width: 38px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.editor { animation: enter .3s ease; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.preview-card { overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.card-heading { height: 52px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.image-stage { height: 450px; position: relative; display: grid; place-items: center; overflow: hidden; background: #121316; }
.image-stage img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.checkerboard { background-color: #e7e7e7; background-image: linear-gradient(45deg,#cfcfcf 25%,transparent 25%),linear-gradient(-45deg,#cfcfcf 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#cfcfcf 75%),linear-gradient(-45deg,transparent 75%,#cfcfcf 75%); background-size: 22px 22px; background-position: 0 0,0 11px,11px -11px,-11px 0; }
.result-light { background: #fff; }
.result-dark { background: #202329; }
.empty-result { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #666c75; }
.empty-result svg { width: 46px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.background-switcher { display: flex; gap: 7px; direction: ltr; margin-right: auto; }
.swatch { width: 19px; height: 19px; padding: 0; border: 2px solid transparent; border-radius: 50%; cursor: pointer; outline: 1px solid #4c515a; }
.swatch.active { border-color: var(--surface); outline-color: var(--accent); }
.swatch.checker { background: conic-gradient(#ddd 25%,#777 0 50%,#ddd 0 75%,#777 0); background-size: 8px 8px; }
.swatch.light { background: white; }.swatch.dark { background: #25282e; }
.processing { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #14161bf0; color: var(--text); }
.spinner { width: 36px; height: 36px; margin-bottom: 5px; border: 3px solid #343841; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

.control-bar { margin-top: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.control-spacer { flex: 1; min-height: 45px; }
.actions { display: flex; gap: 9px; }
.button { min-height: 45px; padding: 0 18px; border: 0; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-decoration: none; font-weight: 750; cursor: pointer; transition: .18s; white-space: nowrap; }
.button:hover { transform: translateY(-1px); }.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.primary { background: var(--accent); color: #111; }.secondary { color: #d5d8de; background: #2a2d34; }.download { color: #111; background: var(--accent); }

.error-box { position: fixed; z-index: 10; left: 25px; bottom: 25px; max-width: 420px; padding: 16px 18px; border: 1px solid #ff6b6b55; border-radius: 13px; background: #2b1719; box-shadow: 0 16px 40px #0008; display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; }
.error-box span { color: #e0c4c4; font-size: 13px; grid-column: 1; }
.error-box button { color: #d9b7b7; background: none; border: 0; font-size: 24px; cursor: pointer; grid-column: 2; grid-row: 1 / 3; }


@keyframes spin { to { transform: rotate(360deg); } }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 900px) {
  .preview-grid { grid-template-columns: 1fr; }.image-stage { height: 350px; }.control-bar { align-items: stretch; flex-direction: column; }.control-spacer { display: none; }.actions { justify-content: flex-end; }
}
@media (max-width: 600px) {
  main { width: min(100% - 24px, 1180px); }.topbar { height: 62px; padding: 0 14px; }.workspace { margin: 30px 0; }.drop-zone { min-height: 290px; }.image-stage { height: 300px; }.actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }.download { grid-column: 1 / 3; }
}
