:root { color-scheme: dark; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--brand-pitch);
  font-family: var(--type-editorial);
}

body.running { cursor: none; }

#viz {
  display: block;
  width: 100vw;
  height: 100vh;
}

#toast {
  position: fixed;
  z-index: 10;
  bottom: 40px;
  left: 50%;
  max-width: 80vw;
  padding: 10px 18px;
  transform: translateX(-50%);
  overflow: hidden;
  background: rgba(36, 36, 36, 0.94);
  border: 1px solid var(--brand-concrete);
  border-radius: 2px;
  color: var(--brand-paper);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  text-overflow: ellipsis;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

#toast.show { opacity: 1; }

#removeBtn,
#excludedBtn,
#favoriteBtn,
#favoritesBtn {
  position: fixed;
  right: 18px;
  z-index: 10;
  width: 42px;
  height: 42px;
  border: 1px solid var(--brand-concrete);
  border-radius: 50%;
  background: rgba(11, 11, 11, 0.86);
  color: var(--brand-paper);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, background-color 0.15s ease, color 0.15s ease;
}

#removeBtn { bottom: 18px; }
#excludedBtn { bottom: 68px; }
#favoriteBtn { bottom: 118px; }
#favoritesBtn { bottom: 168px; }

body.running #removeBtn,
body.running #excludedBtn,
body.running #favoriteBtn,
body.running #favoritesBtn {
  opacity: 0.6;
  pointer-events: auto;
}

body.running #removeBtn:hover,
body.running #excludedBtn:hover,
body.running #favoriteBtn:hover,
body.running #favoritesBtn:hover,
body.running #removeBtn:focus-visible,
body.running #excludedBtn:focus-visible,
body.running #favoriteBtn:focus-visible,
body.running #favoritesBtn:focus-visible {
  background: var(--brand-paper);
  color: var(--brand-pitch);
  opacity: 1;
}

body.idle #removeBtn,
body.idle #excludedBtn,
body.idle #favoriteBtn,
body.idle #favoritesBtn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}

body.idle { cursor: none; }

#help,
#excludedPanel,
#favoritesPanel {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 11, 11, 0.88);
  color: var(--brand-paper);
  text-align: center;
  transition: opacity 0.4s ease;
}

#help.hidden,
#excludedPanel.hidden,
#favoritesPanel.hidden {
  opacity: 0;
  pointer-events: none;
}

#help .box,
#excludedPanel .box,
#favoritesPanel .box {
  width: min(100%, 520px);
  box-sizing: border-box;
  padding: clamp(24px, 5vw, 42px);
  border-left: 8px solid var(--brand-concrete);
  background: var(--brand-paper);
  box-shadow: 14px 14px 0 rgba(116, 119, 122, 0.45);
  color: var(--brand-pitch);
}

#help .eyebrow {
  margin: 0 0 18px;
  color: var(--brand-charcoal);
  font-family: var(--type-utility);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#help h1,
#excludedPanel h1,
#favoritesPanel h1 {
  margin: 0;
  font-family: var(--type-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: var(--weight-display);
  letter-spacing: -0.07em;
  line-height: 0.92;
}

#help p,
#excludedPanel p,
#favoritesPanel p {
  margin: 12px 0 24px;
  color: var(--brand-charcoal);
  font-size: 14px;
}

#help table {
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

#help td { padding: 5px 10px; }
#help td.k { padding-left: 0; text-align: right; }

kbd {
  display: inline-block;
  min-width: 1.2em;
  padding: 3px 7px;
  border: 1px solid var(--brand-concrete);
  border-bottom-width: 3px;
  border-radius: 2px;
  background: var(--brand-charcoal);
  color: var(--brand-paper);
  font-family: var(--type-utility);
  font-size: 11px;
  text-align: center;
}

#help .go {
  margin-top: 26px;
  color: var(--brand-pitch);
  font-family: var(--type-utility);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#help.loading .go { display: none; }

#help .go.pulse {
  animation: go-pulse 1.6s ease-in-out infinite;
}

@keyframes go-pulse {
  50% { opacity: 0.4; }
}

#help .startup-status {
  margin-top: 26px;
  color: var(--brand-pitch);
  font-family: var(--type-utility);
  font-size: 13px;
}

#help .startup-progress {
  width: min(300px, 70vw);
  height: 6px;
  margin: 12px auto 0;
  overflow: hidden;
  background: var(--brand-concrete);
  border-radius: 0;
}

#help .startup-progress > div {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-pitch);
  transition: width 0.25s linear;
}

#help.loading .startup-progress > div {
  animation: startup-pulse 1.5s ease-in-out infinite;
}

@keyframes startup-pulse {
  50% { opacity: 0.55; }
}

#excludedPanel textarea,
#favoritesPanel textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--brand-concrete);
  border-radius: 0;
  background: var(--brand-charcoal);
  color: var(--brand-paper);
  font-family: var(--type-utility);
  font-size: 13px;
  line-height: 1.5;
}

#excludedPanel .actions,
#favoritesPanel .actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

#excludedPanel .actions button,
#favoritesPanel .actions button {
  padding: 10px 18px;
  border: 1px solid var(--brand-pitch);
  border-radius: 0;
  background: var(--brand-pitch);
  color: var(--brand-paper);
  cursor: pointer;
  font-family: var(--type-utility);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

#excludedPanel .actions button:hover,
#favoritesPanel .actions button:hover {
  background: var(--brand-concrete);
  color: var(--brand-pitch);
}

#excludedPanel #closeExcludedBtn,
#favoritesPanel #closeFavoritesBtn {
  background: transparent;
  color: var(--brand-pitch);
}

@media (max-width: 560px) {
  #help,
  #excludedPanel,
  #favoritesPanel { padding: 16px; }
  #help .box,
  #excludedPanel .box,
  #favoritesPanel .box { border-left-width: 5px; box-shadow: 7px 7px 0 rgba(116, 119, 122, 0.45); }
  #help td { padding: 4px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  #help .startup-progress > div { animation: none; transition: none; }
  #help .go.pulse { animation: none; }
}
