@import url("/fonts.css");

:root {
  --bg: #070708;
  --ink: #c9c8c3;
  --muted: #7c7b76;
  --dim: #4e4d4a;
  --line: rgba(255, 255, 255, 0.16);
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(18, 18, 20, 0.92);
  --radius: 18px;
  --mono: "IBM Plex Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Space Grotesk", "Avenir Next", "Futura", "Century Gothic", sans-serif;
  --vvh: 100dvh;
  --vvw: 100%;
  --vvo: 0px;
  --vvl: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
  color: inherit;
}

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

.scene {
  position: fixed;
  inset: -8%;
  z-index: 0;
  background: #070708 url("/scene.svg") center / cover no-repeat;
  transform-origin: 45% 40%;
  animation: drift 72s ease-in-out infinite alternate;
  pointer-events: none;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='80' height='80' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

@keyframes drift {
  from {
    transform: translate3d(-1.2%, 0.6%, 0) scale(1.04);
  }
  to {
    transform: translate3d(1.4%, -0.8%, 0) scale(1.08);
  }
}

.wrap {
  position: fixed;
  top: var(--vvo);
  left: var(--vvl);
  z-index: 1;
  width: var(--vvw);
  height: var(--vvh);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  overflow: hidden;
}

.window {
  width: min(1080px, 100%);
  height: min(720px, calc(var(--vvh) - 56px));
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow:
    0 40px 90px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(32px) saturate(1.15);
  -webkit-backdrop-filter: blur(32px) saturate(1.15);
  overflow: hidden;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .window,
  .composer,
  .modal {
    background: var(--glass-strong);
  }
}

.bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dots {
  display: flex;
  gap: 7px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.dot.r {
  background: #e26b5a;
}
.dot.y {
  background: #d4b35a;
}
.dot.g {
  background: #6ea56a;
}

.kicker {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
}

.nick-btn,
.linkish {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}

.nick-btn:hover,
.linkish:hover,
.dot:focus-visible,
.nick-btn:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.45);
  outline-offset: 3px;
}

.status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6ea56a;
}

.status.off {
  background: #e26b5a;
}

.status.wait {
  background: #d4b35a;
}

.body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 168px 1fr 168px;
}

.side {
  padding: 18px 16px;
  overflow: auto;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.side a,
.side button.room {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 6px 0;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.side .count {
  color: var(--dim);
  letter-spacing: 0.08em;
}

.log {
  min-width: 0;
  overflow: auto;
  padding: 18px 8px 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overscroll-behavior: contain;
}

.line {
  display: grid;
  grid-template-columns: 54px 112px 1fr;
  gap: 12px;
  padding: 3px 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line time {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.line .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line .txt a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.line.sys {
  grid-template-columns: 54px 1fr;
  color: var(--muted);
}

.composer {
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--glass);
}

.typing {
  min-height: 1.2em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 4px 6px;
}

form.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="text"],
input[type="password"] {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
}

.send {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.home {
  padding: 36px 40px 28px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
}

.section-label {
  margin: 18px 0 0;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

.glass-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.glass-form h2 {
  margin: 0 0 4px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.created {
  margin: 12px 0 0;
  color: #c9c8c3;
}

.room-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.room-chip,
.send.danger {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.send.danger {
  margin-left: 8px;
  color: #e26b5a;
}

.home h1 {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(40px, 7vw, 72px);
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: #e8e6e1;
}

.home p.lead {
  margin: 0 0 36px;
  color: var(--muted);
  max-width: 26em;
}

.rooms {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rooms li {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.rooms a {
  flex: 1;
  padding: 12px 0;
  text-decoration: none;
  font-family: var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
}

.rooms span {
  padding: 12px 0;
  color: var(--dim);
}

.home-foot {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.rooms li.muted {
  color: var(--dim);
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-bg {
  position: fixed;
  top: var(--vvo);
  left: var(--vvl);
  width: var(--vvw);
  height: var(--vvh);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
}

.modal-bg[hidden] {
  display: none;
}

.modal {
  width: min(360px, calc(100% - 32px));
  padding: 22px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

.modal h2 {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.modal p {
  margin: 0 0 16px;
  color: var(--muted);
}

.err {
  color: #e26b5a;
  min-height: 1.2em;
  margin: 8px 0 0;
}

.admin {
  padding: 24px 28px;
  overflow: auto;
  flex: 1;
}

.admin label {
  display: block;
  margin: 14px 0 6px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin pre {
  white-space: pre-wrap;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
}

@media (max-width: 820px) {
  .wrap {
    padding: 0;
  }

  .window {
    width: 100%;
    height: var(--vvh);
    border-radius: 0;
    border: 0;
  }

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

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

  .side {
    display: none;
  }

  .side.open {
    display: block;
    position: absolute;
    top: 49px;
    bottom: 72px;
    width: min(220px, 80vw);
    background: rgba(10, 10, 12, 0.88);
    backdrop-filter: blur(20px);
    z-index: 2;
    border-right: 1px solid var(--line);
  }

  .side.people.open {
    right: 0;
    border-right: 0;
    border-left: 1px solid var(--line);
  }

  .line {
    grid-template-columns: 48px 88px 1fr;
    gap: 8px;
    padding: 4px 8px;
  }

  .home {
    padding: 20px 16px 16px;
  }

  .home h1 {
    font-size: clamp(32px, 9vw, 48px);
  }

  .home p.lead {
    margin: 0 0 16px;
  }

  .section-label {
    margin-top: 10px;
  }

  .log {
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene {
    animation: none;
  }
}
