:root{
  --bg0:#05070a;
  --bg2:#0b1020;
  --ink:#e9f0ff;
  --dim:#b9c4db;
  --mut:#7f8aa3;
  --good:#7dffba;
  --warn:#ff4b7c;
  --key:#86b1ff;
  --line:rgba(233,240,255,.12);
  --shadow: 0 18px 70px rgba(0,0,0,.65);
  --radius:18px;
  --pad:16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --rot: 0;
  --wobble: 0;
  --stability: 1;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }

body{
  margin:0;
  font-family:var(--mono);
  color:var(--ink);

  background:
    radial-gradient(1200px 720px at 15% 10%, rgba(134,177,255,.16), transparent 58%),
    radial-gradient(950px 620px at 78% 32%, rgba(255,75,124,.10), transparent 62%),
    radial-gradient(980px 650px at 50% 90%, rgba(125,255,186,.06), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg2));
  background-attachment: fixed;

  height: 100svh;
  overflow: hidden;

  display:flex;
  flex-direction:column;
}

@supports (height: 100dvh){
  body{ height: 100dvh; }
}

/* CRT overlays */
body::before,
body::after{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:0;
}

/* Scanlines */
body::before{
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.040) 0px,
    rgba(255,255,255,.040) 1px,
    transparent 2px,
    transparent 7px
  );
  opacity: .20;
  mix-blend-mode: overlay;
  animation: scanFlicker 6.5s infinite linear;
}

/* Vignette + grain */
body::after{
  background:
    radial-gradient(120% 85% at 50% 35%,
      rgba(0,0,0,0) 35%,
      rgba(0,0,0,.45) 70%,
      rgba(0,0,0,.74) 100%
    ),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:center;
  background-size:cover;
  opacity: .18;
  mix-blend-mode: overlay;
  animation: grainDrift 9s infinite linear;
}

@keyframes scanFlicker{
  0%,100%{ opacity:.20; }
  50%{ opacity:.16; }
}
@keyframes grainDrift{
  0%{ transform: translate3d(0,0,0); opacity:.18; }
  50%{ transform: translate3d(-0.6%,0.35%,0); opacity:.20; }
  100%{ transform: translate3d(0,0,0); opacity:.18; }
}

/* Reduced effects mode */
.reduced body::before,
.reduced body::after{
  opacity:0 !important;
  animation:none !important;
}

.wrap{
  z-index:1;
  width:min(1000px, 100%);
  margin:0 auto;
  padding: 0 var(--pad);
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px;
  padding: 14px 0 8px;
}

.brand{ display:flex; flex-direction:column; gap:6px; }
.title{
  font-size: 16px;
  letter-spacing: .7px;
  text-transform: uppercase;
}
.subtitle{
  color:var(--mut);
  font-size: 12px;
  letter-spacing:.35px;
}

.controls{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

label.switch{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 12px;
  color: var(--dim);
  user-select:none;
}
input[type="checkbox"]{ accent-color: var(--key); }

button, .chip, .q{
  appearance:none;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .3px;
  cursor:pointer;
  user-select:none;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
button:hover, .chip:hover, .q:hover{
  transform: translateY(-1px);
  border-color: rgba(134,177,255,.38);
  background: rgba(134,177,255,.08);
}
button:active{ transform: translateY(0); }
button:focus-visible{
  outline: 2px solid rgba(134,177,255,.45);
  outline-offset: 2px;
}
.chip.danger{
  border-color: rgba(255,75,124,.40);
  background: rgba(255,75,124,.08);
}

.meterRow{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  padding: 0 0 10px;
}
.meter{
  width: 220px;
  height: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow:hidden;
  background: rgba(255,255,255,.03);
}
.meter > i{
  display:block;
  height:100%;
  width:100%;
  transform-origin: left center;
  transform: scaleX(var(--stability, 1));
  background: linear-gradient(90deg,
    rgba(125,255,186,.75),
    rgba(134,177,255,.75),
    rgba(255,75,124,.65)
  );
}
.tiny{
  color: var(--mut);
  font-size: 12px;
}
.muted{ opacity:.70; }

main{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap: 12px;
  padding-bottom: 12px;
}

#terminal{
  flex:1;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  border:1px solid rgba(134,177,255,.18);
  border-radius: var(--radius);
  background: rgba(0,0,0,.35);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0,0,0,.25) inset;
  padding: 14px;

  text-shadow:
    0 0 calc(6px + (var(--rot) * 10px)) rgba(134,177,255,.11),
    0 0 calc(4px + (var(--rot) * 8px)) rgba(255,75,124,.06);

  filter:
    contrast(calc(1.00 + (var(--rot) * 0.20)))
    saturate(calc(1.00 + (var(--rot) * 0.15)));
}

@keyframes wobble{
  0%,100%{ transform: translate3d(0,0,0); }
  20%{ transform: translate3d(calc(var(--wobble) * 0.8px), 0, 0); }
  40%{ transform: translate3d(calc(var(--wobble) * -0.6px), calc(var(--wobble) * 0.4px), 0); }
  60%{ transform: translate3d(calc(var(--wobble) * 0.5px), calc(var(--wobble) * -0.3px), 0); }
  80%{ transform: translate3d(calc(var(--wobble) * -0.4px), 0, 0); }
}
#terminal{ animation: wobble 6.2s infinite linear; }
.reduced #terminal{
  animation:none !important;
  filter:none !important;
  text-shadow:none !important;
}

.line{
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 6px;
}
.line.dim{ color: rgba(185,196,219,.88); }
.line.k{ color: rgba(134,177,255,.95); }
.line.g{ color: rgba(125,255,186,.92); }
.line.w{ color: rgba(255,75,124,.92); }

.hr{
  height:1px;
  background: rgba(233,240,255,.10);
  margin: 10px 0;
}

#terminal a{
  color: rgba(134,177,255,.95);
  text-decoration:none;
  border-bottom:1px dashed rgba(134,177,255,.35);
}
#terminal a:hover{ border-bottom-color: rgba(134,177,255,.70); }

/* Anything you don't want corrupted goes inside this */
.no-corrupt{ filter:none !important; }

.cmdRow{
  display:flex;
  gap: 10px;
  align-items:center;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.cmdLabel{
  color: var(--mut);
  font-size: 12px;
  letter-spacing:.35px;
}
#cmd{
  flex:1;
  min-width:0;
  border-radius: 14px;
  border: 1px solid rgba(233,240,255,.16);
  background: rgba(0,0,0,.40);
  color: var(--ink);
  padding: 12px 12px;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25) inset;
}
#cmd::placeholder{ color: rgba(127,138,163,.85); }
#cmd:focus{
  border-color: rgba(134,177,255,.45);
  box-shadow:
    0 0 0 2px rgba(134,177,255,.20),
    0 0 0 1px rgba(0,0,0,.25) inset;
}

.quickRow{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  padding-bottom: 6px;
}

.footer{
  padding: 10px 0 16px;
  border-top: 1px solid rgba(233,240,255,.10);
  color: var(--mut);
  font-size: 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  flex-wrap:wrap;
}

@media (max-height: 520px){
  body{ overflow:auto; }
  #terminal{ height: 45vh; }
}
@media (max-width: 520px){
  .title{ font-size: 14px; }
  button, .chip, .q{ padding: 9px 11px; }
  #terminal{ padding: 12px; }
}