:root {
  color-scheme: dark;
  --bg: #080a10;
  --panel: rgba(12, 17, 29, 0.86);
  --panel-solid: #0f1422;
  --line: rgba(130, 223, 255, 0.22);
  --text: #eef8ff;
  --muted: #9db3c7;
  --cyan: #5ce1ff;
  --green: #7dff9c;
  --coral: #ff6f7d;
  --gold: #ffd166;
  --violet: #a78bfa;
  --shadow: rgba(0, 0, 0, 0.45);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(92, 225, 255, 0.14), transparent 28rem),
    radial-gradient(circle at 80% 70%, rgba(125, 255, 156, 0.1), transparent 24rem), linear-gradient(135deg, #080a10 0%, #12101b 45%, #071018 100%);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 82%);
}

#signal-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.42;
  pointer-events: none;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  align-items: center;
}

.intercept-panel,
.invite-modal,
.invite-popup {
  position: relative;
  z-index: 1;
}

.intercept-panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 20, 34, 0.92), rgba(8, 12, 22, 0.9));
  box-shadow:
    0 28px 80px var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 26px;
  border-bottom: 1px solid rgba(130, 223, 255, 0.16);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 5.6rem);
  text-transform: uppercase;
}

h2 {
  font-size: clamp(2rem, 5vw, 4.6rem);
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 190px;
}

.status-pill,
.source-pill,
.level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.status-pill.complete {
  color: #0a1510;
  background: var(--green);
  border-color: transparent;
}

.monitor {
  position: relative;
  height: min(58vh, 560px);
  min-height: 420px;
  margin: 26px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr) auto;
  border: 1px solid rgba(130, 223, 255, 0.2);
  background:
    linear-gradient(rgba(92, 225, 255, 0.08), transparent 2px), linear-gradient(90deg, rgba(92, 225, 255, 0.06), transparent 2px),
    rgba(3, 8, 16, 0.74);
  background-size:
    100% 52px,
    52px 100%,
    auto;
}

.monitor::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 1px, transparent 3px, transparent 7px);
  mix-blend-mode: screen;
}

.monitor.glitch {
  animation: glitch-shift 260ms steps(2, end) 3;
}

.monitor-header {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(130, 223, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.red {
  background: var(--coral);
}

.yellow {
  background: var(--gold);
}

.green {
  background: var(--green);
}

.signal-label {
  margin-left: auto;
  color: var(--green);
  font:
    800 0.75rem/1 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

.conversation {
  position: relative;
  z-index: 1;
  list-style: none;
  margin: 0;
  padding: 22px;
  min-height: 0;
  overflow-y: auto;
  /* overscroll-behavior: contain; */
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.conversation::before {
  content: "";
  margin-top: auto;
}

.message {
  width: min(730px, 100%);
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 14, 25, 0.76);
  color: #dcecff;
  font:
    650 1rem/1.5 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  transform: translateY(8px);
  opacity: 0;
  animation: message-in 320ms ease forwards;
}

.message.from-person-b {
  align-self: flex-end;
  border-color: rgba(125, 255, 156, 0.24);
}

.speaker {
  display: block;
  margin-bottom: 5px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message.from-person-b .speaker {
  color: var(--green);
}

.disconnect {
  position: relative;
  z-index: 1;
  margin: 0 22px 22px;
  padding: 16px;
  border: 1px solid rgba(255, 111, 125, 0.34);
  background: rgba(255, 111, 125, 0.1);
  color: #ffdbe0;
  font:
    800 0.92rem/1 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

.control-strip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 0 26px 26px;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--cyan);
  color: #031018;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 0 26px rgba(92, 225, 255, 0.3);
}

.primary-button:disabled {
  cursor: default;
  filter: grayscale(0.55);
  opacity: 0.7;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.16);
  font-size: 0.72rem;
}

.meter {
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--green));
  transition: width 420ms ease;
}

.unread-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 18px rgba(255, 111, 125, 0.8);
}

.invite-popup {
  position: fixed;
  right: clamp(16px, 4vw, 42px);
  bottom: clamp(16px, 4vw, 42px);
  z-index: 4;
  width: min(460px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  text-align: left;
  border: 1px solid rgba(92, 225, 255, 0.34);
  background: rgba(13, 18, 31, 0.96);
  box-shadow:
    0 22px 60px var(--shadow),
    0 0 28px rgba(92, 225, 255, 0.18);
  animation: popup-in 1s ease forwards;
}

/* Make the invite-popup blink */
@keyframes blink {
  0%,
  75%,
  100% {
    opacity: 1;
  }
  90% {
    opacity: 0;
  }
}

.invite-popup {
  animation: blink 3s infinite;
}

.invite-popup small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.popup-open-label {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: none;
}

.invite-modal {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 13, 0.72);
  backdrop-filter: blur(10px);
}

.invite-card {
  position: relative;
  width: min(900px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  border: 1px solid rgba(130, 223, 255, 0.2);
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(92, 225, 255, 0.12) 48% 52%, transparent 52%),
    linear-gradient(transparent 0 48%, rgba(125, 255, 156, 0.12) 48% 52%, transparent 52%), rgba(13, 18, 31, 0.96);
  background-attachment: local, local, scroll;
  background-size:
    90px 90px,
    90px 90px,
    auto;
  box-shadow: 0 28px 80px var(--shadow);
  padding: clamp(24px, 5vw, 52px);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: modal-in 320ms ease forwards;
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 34px;
  z-index: 2;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(125, 255, 156, 0.46);
  border-radius: 50%;
  background: rgba(13, 18, 31, 0.9);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.38),
    0 0 22px rgba(125, 255, 156, 0.24);
  transform: translateX(-50%);
  animation: cue-bounce 1.4s ease-in-out infinite;
}

.scroll-cue::before {
  content: "";
  width: 14px;
  height: 14px;
  border-right: 3px solid var(--green);
  border-bottom: 3px solid var(--green);
  transform: translateY(-3px) rotate(45deg);
}

.invite-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.level-badge {
  flex: 0 0 auto;
  color: #06140c;
  background: var(--green);
  border-color: transparent;
}

.avatar-row {
  position: relative;
  display: flex;
  gap: 10px;
  margin: 0 0 28px;
}

.avatar {
  width: 42px;
  height: 42px;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.45);
  clip-path: polygon(50% 0, 100% 28%, 100% 74%, 50% 100%, 0 74%, 0 28%);
}

.avatar.blue {
  background: var(--cyan);
}

.avatar.coral {
  background: var(--coral);
}

.avatar.mint {
  background: var(--green);
}

.avatar.gold {
  background: var(--gold);
}

.invite-card p {
  position: relative;
  max-width: 760px;
  color: #dce9f8;
  font-size: clamp(1rem, 1.8vw, 1.16rem);
  line-height: 1.65;
}

.signature {
  color: var(--cyan);
  font-weight: 900;
}

.invite-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 28px;
}

.secondary-button {
  background: var(--green);
  box-shadow: 0 0 26px rgba(125, 255, 156, 0.25);
}
/* Disabled */
.secondary-button:disabled {
  background: rgba(125, 255, 156, 0.5);
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  box-shadow: none;
}

.power-bar {
  display: flex;
  gap: 7px;
}

.power-bar span {
  width: 32px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  transition:
    background 300ms ease,
    transform 300ms ease;
}

.power-bar.charged span {
  background: var(--gold);
  transform: translateY(-2px);
}

.accepted {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(125, 255, 156, 0.28);
  background: rgba(125, 255, 156, 0.1);
  color: #dfffe8;
  font-weight: 800;
}

.accepted p {
  margin: 0 0 14px;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(125, 255, 156, 0.38);
  background: rgba(5, 18, 12, 0.58);
  color: #eaffef;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  padding: 10px 20px;
  text-align: center;
}

.download-button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.download-button:hover {
  background: rgba(125, 255, 156, 0.2);
}

[hidden] {
  display: none !important;
}

@keyframes message-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes popup-in {
  from {
    transform: translateY(18px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes modal-in {
  from {
    transform: translateY(18px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes cue-bounce {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, 8px);
  }
}

@keyframes glitch-shift {
  0% {
    transform: translate(0);
    filter: hue-rotate(0deg);
  }
  50% {
    transform: translate(6px, -2px);
    filter: hue-rotate(40deg);
  }
  100% {
    transform: translate(-4px, 3px);
    filter: hue-rotate(-30deg);
  }
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 10px 0;
    align-items: start;
  }

  .topbar,
  .invite-header {
    flex-direction: column;
  }

  .eyebrow {
    font-size: 0.72rem;
  }

  .topbar h1 {
    font-size: clamp(1.8rem, 7vw, 4.6rem);
  }

  .status-stack {
    align-items: stretch;
    width: 100%;
  }

  .monitor {
    min-height: 350px;
    margin: 12px;
    max-height: calc(100vh - 400px);
    max-height: calc(100dvh - 400px);
  }

  .conversation {
    padding: 14px;
  }

  .message {
    font-size: 0.88rem;
  }

  .control-strip {
    grid-template-columns: 1fr;
    padding: 0 12px 12px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .download-button {
    width: 100%;
  }

  .invite-modal {
    padding: 10px;
    align-items: start;
    overflow-y: auto;
  }

  .invite-card {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  .invite-popup {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
  }
}
