@property --spinglow-rotate {
  syntax: "<angle>";
  initial-value: 132deg;
  inherits: false;
}

/* Scoped + centered so it won't fight your site CSS */
#kleptos {
  --bg:#191919;
  --card:#1d1d1d;
  --muted:#a0a0a0;
  --text:#e7e7e7;
  --accent:#f64040;
  --outline:#2a2a2a;
  --tile:#151515;

  --spinwglow-height: 980px;
  --spinwglow-width: 740px;

  --gray:#3a3a3a;
  --yellow:#f6f340;
  --green:#39ce4d;

  color:var(--text);
}

/* center the whole app */
#kleptos .grid {
  max-width: var(--spinwglow-width);
  margin: 0 auto;
  padding: 12px 16px 32px;
}

/* hero */
#kleptos .hero{ padding:18px 16px 0; text-align:center; }
#kleptos .hero h1{ margin:0 0 6px; font-size:clamp(22px, 3.5vw, 32px); letter-spacing:.4px; }
#kleptos .muted{ color:var(--muted); }

/* toolbar */
#kleptos .toolbar{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; padding: 5px; flex-wrap:wrap;}
#kleptos .stats{ display:flex; gap:14px; flex-wrap:wrap; }
#kleptos .label{ color:var(--muted); margin-right:6px; }

/* url row */
#kleptos .urlInfo{
  display:flex;
  align-items:flex-start;
  gap:12px;
  margin-top: 15px;
  margin-bottom: 15px;
  padding: 5px;
}

/* buttons */
#kleptos .btn{
  background: var(--accent);
  color:#191919;
  border:none;
  padding:10px 14px;
  border-radius:10px;
  font-weight:700;
  cursor:pointer;
  flex:0 0 auto;
}
#kleptos .btn:disabled{ opacity:.6; cursor:not-allowed; }

/* url input */
#kleptos .urlInput {
  width: 300px;
  flex: 1 1 auto;
  height: 20px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  padding: 6px 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}

/* results + video */
#kleptos .urlResults{ margin-top:16px;}
#kleptos .urlResults h2{ font-size:18px; margin: 0px;  padding-left: 5px; padding-right: 5px;}
#kleptos .thumbnail{
  width:100%;
  height:auto;
  /* important: display the real aspect ratio without stretching */
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--outline);
  border-radius:15px;
  margin-top:10px;
}

#kleptos .urlResults a{
  margin:0px;
  padding-left: 5px;
  padding-right: 5px;
  text-decoration: none;
  font-size:14px;
  color:#e1e1e1;
  opacity: 0.7;
  transition: opacity 0.5s ease-in-out;
}
#kleptos .urlResults a:hover{
  text-decoration: underline;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
}

#kleptos .videoInfo{
  display:flex;
  padding:5px;
  gap:8px;
  flex-wrap:wrap;
}

#kleptos .videoInfo p{
  margin: 0px;
  padding-right: 8px;
  font-size: 13px;
  color: var(--muted);
}

#kleptos .playlistInfo {
  display:flex;
  align-items:center;
  gap:10px;
  margin:8px 5px 0 5px;
  padding: 8px 10px;
  border:1px solid var(--outline);
  background: var(--tile);
  border-radius:10px;
}
#kleptos .playlistInfo[hidden]{ display:none !important; }
#kleptos .playlistInfo .pill{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--outline);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
}

@keyframes spin { 0% { --spinglow-rotate: 0deg; } 100% { --spinglow-rotate: 360deg; } }
#kleptos { --halo: clamp(16px, 4vw, 36px); --ring: 2px; }

#kleptos .cardGlow{
  position: relative;
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: 15px;
  padding: 25px;
  margin: 0 auto 0;
  color: #e1e1e1;
  background-size: cover;
  background-position: center;
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow: visible;
}

/* keep real content above the glow */
#kleptos .cardGlow > * { position: relative; z-index: 1; }

#kleptos .cardGlow::before,
#kleptos .cardGlow::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  background-image: linear-gradient(var(--spinglow-rotate), #7f31ff, #f64040);
  animation: spin 2.5s linear infinite;
  pointer-events:none;
  z-index:-1;
}

#kleptos .cardGlow::before{ inset: calc(var(--halo) * -0.1); opacity:1; }
#kleptos .cardGlow::after { filter: blur(calc(var(--spinwglow-height) / 20)); opacity: 1; }

/* Progress bars + Toasts */
#kleptos .progress[hidden]{ display:none !important; }
#kleptos .progress{
  display:flex; align-items:center; gap:12px;
  padding:10px 12px; margin:8px 5px 0 5px;
  border:1px solid var(--outline);
  background: var(--tile);
  border-radius:10px;
}
#kleptos .progress span{ font-size:14px; color: var(--muted); white-space: nowrap; }
#kleptos .progress .bar{
  position:relative; height:6px; flex:1 1 auto;
  background: var(--bg);
  border-radius:999px; overflow:hidden;
  border: 1px solid var(--outline);
}
#kleptos .progress .bar::before{
  content:""; position:absolute; inset:0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  animation: kleptos-indeterminate 1.2s linear infinite;
}
@keyframes kleptos-indeterminate{ from{ transform: translateX(-100%);} to{ transform: translateX(100%);} }
@media (prefers-reduced-motion: reduce){ #kleptos .progress .bar::before{ animation-duration: 2.4s; } }

/* Toasts */
#kleptos .toast[hidden]{ display:none !important; }
#kleptos .toast{
  position: fixed; right: 16px; bottom: 16px; z-index: 10000;
  background: var(--card);
  border: 1.5px solid var(--outline);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  max-width: 420px;
}
#kleptos .toast.error{ border-color: #f64040; }
#kleptos .toast .title{ font-weight: 700; margin-bottom:4px; }
#kleptos .toast .body{ font-size: 14px; color: var(--muted); }

/* Settings Modal */
#kleptos .kmodal[aria-hidden="true"]{ display:none; }
#kleptos .kmodal{ position:fixed; inset:0; z-index:9999; height: auto;}
#kleptos .kmodal__backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.5); backdrop-filter:blur(6px); }
#kleptos .kmodal__dialog{ position:absolute; inset:0; margin:auto; height: 210px; width:min(560px,92vw); background:var(--card); border:1px solid var(--outline); border-radius:14px; box-shadow:0 10px 30px rgba(0,0,0,.45), 0 0 0 1px var(--outline) inset; padding:16px 16px 64px; }
#kleptos .kmodal__close{ position:absolute; top:8px; right:8px; width:34px; height:34px; line-height:34px; border:1px solid var(--outline); background:var(--bg); border-radius:10px; font-size:20px; color:var(--muted); cursor:pointer; }
#kleptos .kmodal__footer{ position:absolute; right:16px; bottom:12px; display:flex; gap:8px; }
#kleptos .kform{ display:grid; gap:12px; margin-top:8px; }
#kleptos .kform__field>span{ display:block; font-size:12px; color:var(--muted); margin:2px 0 6px; }
#kleptos .kform__field input,#kleptos .kform__field select{ width:100%; background:var(--bg); color:#e1e1e1; border:1px solid var(--outline); border-radius:10px; padding:10px 12px; }
#kleptos .kform__check{ display:flex; align-items:center; gap:10px; font-size:14px; color:#e1e1e1;}
#kleptos .kform__row3{ display:grid; grid-template-columns: 1.2fr 1.2fr auto; gap:12px; align-items:end; }
#kleptos .kform__field--checkbox{ padding-bottom:2px;}
#kleptos .btnset{ display:flex; gap:8px; flex-wrap:wrap; }
#kleptos .btnset button{ border:1px solid var(--outline); background:var(--bg); color:#e1e1e1; border-radius:10px; padding:8px 12px; cursor:pointer; }
#kleptos .btnset button.active{ background:var(--accent); color:#111; font-weight:700; }

@media (max-width:560px){
  #kleptos .kform__row3{ grid-template-columns: 1fr; }
}
@media (max-width: 720px){
  #kleptos .kform__row{ grid-template-columns: 1fr; }
  #kleptos .kform__row .urlInput{ width: 100%; }
  #kleptos .videoInfo{ flex-wrap:wrap; }
}
