:root {
  --bg: #050505;
  --bg2: #0a0a0a;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.22);
  --glass-highlight: rgba(255, 255, 255, 0.45);
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --dim: #737373;
  --white: #ffffff;
  --black: #000000;
  --danger: #e5e5e5;
  --radius: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --blur: 18px;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  /* true mono: kill any residual chroma from images/UA */
  filter: none;
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(900px 500px at 15% -5%, rgba(255, 255, 255, 0.08), transparent 55%),
    radial-gradient(700px 420px at 95% 10%, rgba(255, 255, 255, 0.05), transparent 50%),
    linear-gradient(180deg, #0a0a0a 0%, #000 100%);
  min-height: 100vh;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}
.bg-orb-1 {
  width: 420px; height: 420px;
  top: -80px; left: -60px;
  background: radial-gradient(circle, rgba(255,255,255,0.35), transparent 70%);
}
.bg-orb-2 {
  width: 360px; height: 360px;
  bottom: 10%; right: -80px;
  background: radial-gradient(circle, rgba(255,255,255,0.22), transparent 70%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* Liquid glass panels */
.glass {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.04) 40%,
    rgba(255, 255, 255, 0.02) 100%
  );
  backdrop-filter: blur(var(--blur)) saturate(0%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(0%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  position: relative;
}
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    125deg,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(255, 255, 255, 0.06) 18%,
    transparent 42%
  );
  opacity: 0.7;
}

.header {
  margin-bottom: 22px;
  padding: 18px 16px;
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; position: relative; z-index: 1; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, #fff 0%, #bbb 45%, #666 100%);
  box-shadow:
    0 0 24px rgba(255, 255, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; font-weight: 650; color: var(--white); }
.tag { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.privacy {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: var(--text);
  font-size: .92rem;
  line-height: 1.4;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.uploads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 640px) {
  .uploads { grid-template-columns: 1fr; }
}

.drop {
  display: block;
  min-height: 220px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, background .15s, box-shadow .15s;
  overflow: hidden;
  outline: none;
}
.drop:hover, .drop.drag, .drop:focus-visible {
  border-color: rgba(255, 255, 255, 0.55);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.16) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.15);
}
.drop.has-image {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.35);
}

/* Visually hidden but still reachable / clickable via JS — NOT display:none */
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.drop-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 16px;
  text-align: center;
  gap: 8px;
  pointer-events: none; /* let clicks hit the drop container; buttons re-enable */
}
.drop-label {
  font-size: .72rem;
  letter-spacing: .16em;
  font-weight: 700;
  color: var(--white);
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}
.drop-hint {
  color: var(--muted);
  font-size: .9rem;
  max-width: 18ch;
  line-height: 1.35;
}
.drop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 0;
  pointer-events: none;
  filter: grayscale(100%);
}
.drop.has-image .drop-label,
.drop.has-image .drop-hint,
.drop.has-image .btn.browse { display: none; }
.drop.has-image .drop-inner {
  /* keep overlay tappable to replace image */
  min-height: 220px;
}

.btn.browse {
  pointer-events: auto;
  margin-top: 4px;
  padding: 10px 16px;
  font-size: .88rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: var(--white);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.browse:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.55);
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .15s, transform .1s, background .15s, border-color .15s;
  color: var(--text);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, #fff 0%, #e8e8e8 40%, #cfcfcf 100%);
  color: #0a0a0a;
  min-width: 140px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    0 4px 20px rgba(255, 255, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff 0%, #f2f2f2 50%, #ddd 100%);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.45);
}

.status {
  min-height: 1.4em;
  color: var(--muted);
  font-size: .92rem;
  margin: 0 0 18px;
}
.status.error { color: #f5f5f5; text-decoration: underline; text-underline-offset: 3px; }
.status.ok { color: var(--white); }

.result {
  padding: 16px;
}
.result h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  position: relative;
  z-index: 1;
  color: var(--white);
}
.canvas-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  overflow: auto;
  border-radius: 12px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  justify-content: center;
}
#resultCanvas {
  max-width: 100%;
  height: auto;
  display: block;
  /* display-only; pixels also desaturated in JS before toBlob */
  filter: grayscale(100%);
}
.result-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.hint {
  position: relative;
  z-index: 1;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

.footer {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--dim);
  font-size: .8rem;
}
.muted { opacity: .85; }
