:root {
  color-scheme: dark;
  --spin: 0deg;
  --origin-x: 50%;
  --origin-y: 50%;
}

@property --spin {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@property --origin-x {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 50%;
}

@property --origin-y {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 50%;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

button,
a,
input,
label {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button:focus,
a:focus {
  outline: none;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000000;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  color: var(--ink);
}

html {
  --ink: #000000;
  --thumb: #ffffff;
  --ring: #000000;
  --shade: 0.5;
}

html.is-light {
  --ink: #ffffff;
  --thumb: #000000;
  --ring: #ffffff;
}

#rainbow,
.veil {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.rainbow-fallback {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  background: conic-gradient(
    from var(--spin) at var(--origin-x) var(--origin-y),
    #ff0000,
    #ffffff,
    #ff0000,
    #ffffff,
    #ff0000,
    #ffffff,
    #ff0000
  );
  animation:
    spin-rainbow 28s linear infinite,
    drift-rainbow 18s ease-in-out infinite;
}

.rainbow-fallback.is-driven {
  display: block;
  animation: none;
}

.veil {
  z-index: 1;
  pointer-events: none;
  background: #000000;
  opacity: var(--shade, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.stage {
  position: fixed;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.35rem;
  pointer-events: none;
}

.widget {
  pointer-events: auto;
  width: min(100%, 22.5rem);
  padding: 1.05rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  border: 1px solid var(--ink);
  border-radius: 1rem;
  background: var(--thumb);
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  letter-spacing: -0.03em;
  line-height: 1.35;
  touch-action: manipulation;
  transition:
    border-color 0.2s linear,
    background-color 0.2s linear,
    color 0.2s linear;
}

.widget-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.25;
}

.widget-divider {
  width: 100%;
  height: 1px;
  background: var(--ink);
  opacity: 0.22;
  transition: background-color 0.2s linear;
}

.widget-rows {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.widget-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.widget-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.widget-label {
  font-size: 0.72rem;
  line-height: 1.25;
}

.widget-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2rem;
  padding: 0 0.75rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--thumb);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: -0.03em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.18s ease,
    border-color 0.2s linear,
    background-color 0.2s linear,
    color 0.2s linear;
}

@media (hover: hover) and (pointer: fine) {
  .widget-btn:hover {
    transform: scale(0.94);
  }
}

.widget-btn:active {
  transform: scale(0.94);
}

.widget-btn:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.feature-mark {
  width: 1rem;
  height: 1rem;
  display: block;
  flex: 0 0 auto;
}

.footnote {
  position: fixed;
  z-index: 2;
  left: 1.35rem;
  bottom: 1.15rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
  touch-action: pan-x;
  color: var(--ink);
}

.footnote-row {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.credit {
  margin: 0;
  color: var(--ink);
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-transform: lowercase;
}

.darkness {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  color: var(--ink);
  cursor: pointer;
}

.icon {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  flex: 0 0 auto;
  color: var(--ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.darkness input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 7.25rem;
  height: 1.15rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-x;
}

.darkness input[type="range"]:focus {
  outline: none;
}

.darkness input[type="range"]:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 0.35rem;
}

.darkness input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--ink);
  border: 0;
}

.darkness input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0.82rem;
  height: 0.82rem;
  margin-top: -0.38rem;
  border: 0;
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 0 0 1px var(--ring);
  cursor: pointer;
}

.darkness input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--ink);
  border: 0;
}

.darkness input[type="range"]::-moz-range-thumb {
  width: 0.82rem;
  height: 0.82rem;
  border: 0;
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 0 0 1px var(--ring);
  cursor: pointer;
}

@keyframes spin-rainbow {
  to {
    --spin: 360deg;
  }
}

@keyframes drift-rainbow {
  0% {
    --origin-x: 42%;
    --origin-y: 46%;
  }
  50% {
    --origin-x: 58%;
    --origin-y: 54%;
  }
  100% {
    --origin-x: 42%;
    --origin-y: 46%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rainbow-fallback {
    animation: none;
    --spin: 128deg;
    --origin-x: 46%;
    --origin-y: 42%;
  }
}
