:root {
  color-scheme: dark;
  --bg: #050505;
  --fg: #d8d8d8;
  --muted: #858585;
  --line: #2b2b2b;
  --soft: #111;
  --error: #ff8b8b;
  --ok: #a6f3a6;
  --rgb-period: 180px;
  --rgb: repeating-linear-gradient(90deg, #ff003c 0, #ffdf00 30px, #00ff66 60px, #00d5ff 90px, #7a5cff 120px, #ff00d4 150px, #ff003c 180px);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: 30px 16px 18px;
  background: var(--bg);
  color: var(--fg);
  display: grid;
  grid-template-rows: minmax(20px, 1fr) auto minmax(20px, 1fr) auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.5;
}

.page,
footer {
  transition: filter 180ms ease, opacity 180ms ease, transform 180ms ease;
}

body.key-open .page,
body.key-open footer {
  filter: blur(8px);
  opacity: 0.42;
  transform: scale(0.995);
}

button,
input {
  font: inherit;
}

.page {
  grid-row: 2;
  width: min(620px, 100%);
  margin: 0 auto;
}

.site-header {
  margin-bottom: 28px;
  text-align: center;
}

.signal {
  width: 138px;
  height: 2px;
  margin: 0 auto 14px;
  background: var(--rgb);
  background-size: var(--rgb-period) 100%;
  background-repeat: repeat-x;
  box-shadow: 0 0 12px rgb(0 213 255 / 35%);
  animation: signal-slide 8s linear infinite;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  font-weight: 400;
  letter-spacing: 0;
}

.site-header p {
  color: var(--muted);
}

.upload-form {
  display: grid;
  gap: 14px;
}

.drop-zone {
  display: grid;
  min-height: 154px;
  padding: 22px;
  border: 1px dashed var(--line);
  background: var(--soft);
  place-content: center;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drop-zone.is-dragging,
.drop-zone:focus {
  border-color: var(--fg);
  box-shadow: 0 0 0 1px rgb(216 216 216 / 35%);
  outline: none;
}

.file-name {
  margin-top: 6px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.actions {
  display: grid;
  grid-template-columns: auto 0fr;
  gap: 0;
  justify-content: center;
  transition: gap 220ms ease, grid-template-columns 220ms ease;
}

.actions.has-file {
  grid-template-columns: auto auto;
  gap: 10px;
}

.file-picker,
button,
input {
  border: 1px solid var(--line);
  border-radius: 0;
  background: #080808;
  color: var(--fg);
}

.file-picker,
button {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.upload-button {
  max-width: 0;
  padding-right: 0;
  padding-left: 0;
  border-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(-10px);
  transition: max-width 240ms ease, padding 240ms ease, border-width 240ms ease, opacity 180ms ease, transform 240ms ease, color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.actions.has-file .upload-button {
  max-width: 120px;
  padding-right: 12px;
  padding-left: 12px;
  border-width: 1px;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

button:disabled {
  color: #555;
  cursor: not-allowed;
}

button:not(:disabled):hover,
.file-picker:hover {
  border-color: var(--fg);
  background: #0c0c0c;
  box-shadow: 0 8px 20px rgb(0 0 0 / 24%);
  transform: translateY(-1px);
}

button:not(:disabled):active,
.file-picker:active {
  box-shadow: none;
  transform: translateY(0);
}

.key-trigger {
  justify-self: center;
  grid-auto-flow: column;
  gap: 9px;
  min-height: auto;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.key-trigger #key-state {
  color: #555;
}

.key-trigger.has-key #key-state {
  color: var(--ok);
}

.key-trigger:hover,
.key-trigger:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--fg);
  outline: none;
  transform: none;
}

.key-trigger:focus {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  transition: border-color 160ms ease, background 160ms ease;
}

input:focus {
  border-color: var(--fg);
  outline: none;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 220ms ease, transform 220ms ease;
}

.progress-wrap[hidden] {
  display: none;
}

.progress-wrap.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
}

.progress-bar {
  --progress: 0%;
  position: relative;
  width: 100%;
  height: 12px;
  border: 1px solid var(--line);
  background: #080808;
  overflow: hidden;
}

.progress-fill {
  display: block;
  width: var(--progress);
  height: 100%;
  background: var(--fg);
  box-shadow: 0 0 8px rgb(216 216 216 / 25%);
  transition: width 120ms linear;
}

.message {
  min-height: 22px;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.error {
  color: var(--error);
}

.result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.result[hidden] {
  display: none;
}

.result.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.result .field {
  min-width: 0;
}

footer {
  grid-row: 4;
  display: flex;
  justify-content: center;
  gap: 8px;
  width: min(620px, 100%);
  margin: 0 auto;
  color: var(--muted);
  font-size: 12px;
}

footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

footer a:hover {
  color: var(--fg);
}

.cursor-dot {
  display: none;
}

.key-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(0 0 0 / 36%);
  backdrop-filter: blur(5px);
}

.key-overlay[hidden] {
  display: none;
}

.key-dialog {
  width: min(360px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  background: rgb(8 8 8 / 92%);
  box-shadow: 0 16px 60px rgb(0 0 0 / 48%);
  animation: key-in 180ms ease both;
}

.key-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.key-actions button {
  min-width: 78px;
}

@media (min-width: 761px) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  html.has-cursor,
  html.has-cursor * {
    cursor: none !important;
  }

  .cursor-dot {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    width: 10px;
    height: 10px;
    border: 1px solid rgb(216 216 216 / 60%);
    border-radius: 999px;
    background: rgb(216 216 216 / 24%);
    box-shadow: 0 0 22px rgb(216 216 216 / 10%);
    opacity: 0;
    pointer-events: none;
    transform: translate3d(-100px, -100px, 0) translate(-50%, -50%);
    transition: opacity 160ms ease, width 160ms ease, height 160ms ease, background 160ms ease, border-color 160ms ease;
  }

  .cursor-dot.is-visible {
    opacity: 1;
  }

  .cursor-dot.is-hovering {
    width: 22px;
    height: 22px;
    border-color: rgb(216 216 216 / 85%);
    background: rgb(216 216 216 / 10%);
  }

  .cursor-dot.is-pressing {
    width: 7px;
    height: 7px;
    background: rgb(216 216 216 / 42%);
  }
}

@media (max-width: 520px) {
  body {
    padding-top: 22px;
  }

  .result {
    grid-template-columns: 1fr;
  }

  .actions,
  .actions.has-file {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .upload-button {
    max-width: 100%;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    transform: translateY(-8px);
  }

  .actions.has-file .upload-button {
    max-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
    transform: translateY(0);
  }

  .file-picker,
  button {
    width: 100%;
    text-align: center;
  }

  .key-trigger {
    width: auto;
  }

  .key-actions button {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes key-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes signal-slide {
  from {
    background-position: 0 0;
  }

  to {
    background-position: var(--rgb-period) 0;
  }
}
