:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #111111;
  --dot: rgba(17, 17, 17, 0.085);
  --dot-soft: rgba(17, 17, 17, 0.045);
  --edge-x: max(18px, env(safe-area-inset-right));
  --edge-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, "Courier New",
    monospace;
}

.stealth-stage {
  position: fixed;
  inset: 0;
  display: grid;
  overflow: hidden;
  background: #ffffff;
  place-items: center;
}

.stealth-stage::after {
  position: fixed;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, #ffffff 0, transparent 18%, transparent 82%, #ffffff 100%),
    linear-gradient(180deg, #ffffff 0, transparent 18%, transparent 82%, #ffffff 100%);
  opacity: 0.72;
  pointer-events: none;
}

.dot-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100dvh;
}

h1 {
  position: relative;
  z-index: 2;
  margin: 0;
}

.stealth-trigger {
  padding: 8px 15px;
  color: var(--ink);
  background: #ffffff;
  border: 0;
  box-shadow: 0 0 0 1px #ffffff, 0 0 22px 14px rgba(255, 255, 255, 0.96);
  font: 500 14px/1 "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
    "Courier New", monospace;
  letter-spacing: 0;
  cursor: pointer;
  text-align: center;
  text-transform: lowercase;
}

.stealth-trigger:focus-visible,
.corner-nav a:focus-visible {
  outline: 1px solid rgba(17, 17, 17, 0.46);
  outline-offset: 3px;
}

.chat-form button:focus-visible {
  outline: 0;
}

.stealth-chat {
  position: fixed;
  top: calc(50% + 34px);
  left: 50%;
  z-index: 2;
  width: min(350px, calc(100vw - 36px));
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition:
    opacity 280ms ease,
    transform 280ms ease;
}

.stealth-chat::before {
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: 30px;
  content: "";
}

h1:hover + .stealth-chat,
h1:focus-within + .stealth-chat,
.stealth-chat:hover,
.stealth-chat:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.chat-output {
  max-height: min(220px, 34dvh);
  overflow: auto;
  min-height: 0;
  margin: 0 0 14px;
  padding: 0 2px;
  color: rgba(17, 17, 17, 0.82);
  font: 12px/1.55 "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
    "Courier New", monospace;
  text-align: left;
  white-space: pre-wrap;
}

.chat-output:empty {
  display: none;
}

.chat-note {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 7px;
  margin: 12px 0 0;
  color: rgba(17, 17, 17, 0.54);
  font: 10px/1.45 "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
    "Courier New", monospace;
  text-align: left;
  text-transform: lowercase;
}

.chat-note[hidden] {
  display: none;
}

.chat-note-mark {
  display: inline-grid;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  color: rgba(17, 17, 17, 0.72);
  border: 1px solid rgba(17, 17, 17, 0.2);
  border-radius: 50%;
  font-size: 7px;
  line-height: 1;
}

.chat-form {
  position: relative;
  display: block;
  padding: 6px;
  background: #ffffff;
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: 18px;
  box-shadow:
    0 0 22px 14px rgba(255, 255, 255, 0.96);
}

.chat-form:focus-within {
  border-color: rgba(17, 17, 17, 0.34);
}

.chat-form textarea,
.chat-form button {
  min-width: 0;
  color: var(--ink);
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  font: 13px/1 "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
    "Courier New", monospace;
}

.chat-form textarea {
  display: block;
  width: 100%;
  min-height: 30px;
  max-height: 88px;
  padding: 8px 38px 6px 10px;
  overflow: hidden;
  line-height: 1.25;
  outline: 0;
  resize: none;
}

.chat-form textarea::placeholder {
  color: rgba(17, 17, 17, 0.42);
}

.chat-form button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.corner-nav {
  position: fixed;
  right: var(--edge-x);
  bottom: var(--edge-bottom);
  z-index: 2;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.corner-nav a {
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 0 0 1px #ffffff, 0 0 18px 10px rgba(255, 255, 255, 0.94);
  font: 500 11px/1 "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
    "Courier New", monospace;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: lowercase;
}

@media (max-width: 520px) {
  :root {
    --edge-x: max(14px, env(safe-area-inset-right));
    --edge-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .stealth-trigger {
    padding: 8px 12px;
  }

  .stealth-chat {
    top: calc(50% + 32px);
    width: min(350px, calc(100vw - 28px));
  }

  .chat-form textarea,
  .chat-form button {
    font-size: 12px;
  }

  .corner-nav {
    gap: 5px;
  }

  .corner-nav a {
    padding: 7px 8px;
    font-size: 10px;
  }
}

@media (max-height: 460px) {
  .stealth-chat {
    top: calc(50% + 24px);
  }

  .chat-output {
    max-height: 26dvh;
  }
}
