:root {
  --ink-hi: #ffffffbb;
  --ink-mid: #ffffff88;
  --ink-low: #ffffff44;
  --line: #ffffff33;
  --line-accent: #ff2c4544;
  --focus: #ffd0d8;
  --invert-bg: #ffffffee;
  --invert-ink: #000000;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Space Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

#canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

#preloader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #fff;
  font-size: 20px;
}

.ui-layer {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.corner-box,
.corner-chip {
  --corner-size: 8px;
  --corner-line: var(--line);
  background-image:
    linear-gradient(var(--corner-line), var(--corner-line)),
    linear-gradient(var(--corner-line), var(--corner-line)),
    linear-gradient(var(--corner-line), var(--corner-line)),
    linear-gradient(var(--corner-line), var(--corner-line)),
    linear-gradient(var(--corner-line), var(--corner-line)),
    linear-gradient(var(--corner-line), var(--corner-line)),
    linear-gradient(var(--corner-line), var(--corner-line)),
    linear-gradient(var(--corner-line), var(--corner-line));
  background-repeat: no-repeat;
  background-size:
    var(--corner-size) 1px,
    1px var(--corner-size),
    var(--corner-size) 1px,
    1px var(--corner-size),
    var(--corner-size) 1px,
    1px var(--corner-size),
    var(--corner-size) 1px,
    1px var(--corner-size);
  background-position:
    left top,
    left top,
    right top,
    right top,
    left bottom,
    left bottom,
    right bottom,
    right bottom;
}

.corner-chip {
  --corner-size: 6px;
}

.chat-zone {
  position: absolute;
  left: 40px;
  top: 132px;
  bottom: 159px;
  width: 352px;
  pointer-events: auto;
}

.chat-history {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 42px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 0 2px;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.chat-history::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.chat-message {
  font-size: 11px;
  line-height: 1.5;
  padding: 6px 10px;
  transition: opacity 140ms ease;
}

.chat-message p {
  margin: 0;
  white-space: pre-line;
}

.chat-message.user {
  align-self: flex-end;
  width: fit-content;
  max-width: 280px;
  color: #ffffffaa;
}

.chat-message.bot {
  align-self: flex-start;
  width: 100%;
  color: #ffffff77;
}

.corner-bot {
  --corner-size: 6px;
  --corner-line: var(--line-accent);
}

.chat-input {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  font-size: 11px;
  color: var(--ink-low);
  transition: background-color 160ms ease, color 160ms ease;
}

.chat-input:hover,
.chat-input:focus-within {
  --corner-line: #00000033;
  background-color: var(--invert-bg);
  color: var(--invert-ink);
}

.chat-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
}

.chat-input input::placeholder {
  color: inherit;
}

.chat-input button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.corner-chip:focus,
.corner-chip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.chat-input input:focus,
.chat-input button:focus {
  outline: none;
}

.contact-zone {
  position: absolute;
  right: 40px;
  bottom: 157px;
  width: 320px;
  pointer-events: none;
}

.contact-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  pointer-events: auto;
}

.contact-links::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.corner-chip {
  height: 28px;
  padding: 6px 12px;
  color: var(--ink-mid);
  text-decoration: none;
  font-size: 11px;
  line-height: 1.4;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    transform 120ms ease;
}

.corner-chip:hover,
.corner-chip:focus-visible,
.corner-chip:active {
  --corner-line: #00000033;
  background-color: var(--invert-bg);
  color: var(--invert-ink);
}

.corner-chip:active {
  transform: translateY(1px);
}

@media (max-width: 980px) {
  .contact-zone {
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: auto;
    width: auto;
  }

  .contact-links {
    justify-content: center;
    gap: 6px;
    padding-bottom: 2px;
  }

  .chat-zone {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: 16px;
    top: auto;
    height: min(38dvh, 250px);
  }

  .chat-history {
    bottom: 44px;
  }

  .chat-message.user {
    max-width: 78%;
  }
}
