/* ── Presence stage ── */
.presence-stage {
  --lanyard-accent: var(--accent, #00e8ff);
  --lanyard-accent-soft: var(--accent-soft, rgba(0, 232, 255, 0.16));
  position: relative;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 4.5rem 0 3.25rem;
  min-height: 28rem;
  isolation: isolate;
}

.presence-stage .lanyard-card {
  margin: 0;
}

.presence-stage__hint {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  z-index: 3;
  transition: color 0.25s ease;
}

.presence-stage__hint svg {
  opacity: 0.7;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.presence-stage__hint:hover,
.presence-stage.is-holding .presence-stage__hint {
  color: var(--text);
}

.presence-stage.is-holding .presence-stage__hint svg {
  transform: scale(1.15) rotate(45deg);
  opacity: 1;
}

.presence-stage.is-pulsed .presence-stage__hint {
  color: var(--lanyard-accent);
}

/* ── Lanyard card ── */
.lanyard-card {
  --lanyard-accent: var(--accent, #00e8ff);
  --lanyard-accent-soft: var(--accent-soft, rgba(0, 232, 255, 0.16));
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 2.25rem auto 0;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--lanyard-accent) 20%);
  border-radius: var(--radius, 2px);
  background: color-mix(in srgb, var(--surface) 92%, var(--bg) 8%);
  backdrop-filter: blur(18px);
  overflow: hidden;
  text-align: left;
}

.lanyard-card__mesh {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  background-image:
    linear-gradient(color-mix(in srgb, var(--line) 35%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--line) 35%, transparent) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 90% 80% at 30% 40%, #000, transparent 75%);
}

.lanyard-card__glow {
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  background: radial-gradient(ellipse 50% 45% at 72% 38%, var(--lanyard-accent-soft), transparent 68%);
  opacity: 0.85;
  transition: opacity 0.5s ease;
}

.lanyard-card__scan {
  position: absolute;
  left: 0;
  right: 0;
  top: -32%;
  height: 32%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    color-mix(in srgb, var(--lanyard-accent) 18%, transparent) 45%,
    transparent 100%
  );
  opacity: 0.55;
  pointer-events: none;
  z-index: 4;
  animation: lanyardScan 3.6s linear infinite;
}

@keyframes lanyardScan {
  0% { top: -32%; }
  100% { top: 100%; }
}

.lanyard-card__corner {
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--lanyard-accent);
  border-style: solid;
  opacity: 0.55;
  z-index: 5;
  transition: opacity 0.35s ease, border-color 0.35s ease, transform 0.4s ease;
}

.lanyard-card__corner--tl { top: 8px; left: 8px; border-width: 1px 0 0 1px; }
.lanyard-card__corner--tr { top: 8px; right: 8px; border-width: 1px 1px 0 0; }
.lanyard-card__corner--bl { bottom: 8px; left: 8px; border-width: 0 0 1px 1px; }
.lanyard-card__corner--br { bottom: 8px; right: 8px; border-width: 0 1px 1px 0; }

.presence-stage.is-holding .lanyard-card,
.presence-stage.is-pulsed .lanyard-card {
  border-color: color-mix(in srgb, var(--lanyard-accent) 55%, var(--line));
}

.presence-stage.is-holding .lanyard-card__glow,
.presence-stage.is-pulsed .lanyard-card__glow {
  opacity: 1;
}

.presence-stage.is-holding .lanyard-card__corner,
.presence-stage.is-pulsed .lanyard-card__corner {
  opacity: 1;
  border-color: var(--lanyard-accent);
}

.lanyard-card__head {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.35rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 35%, transparent);
}

.lanyard-card__head-left {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.lanyard-card__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.lanyard-card__sync {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.75;
}

.lanyard-card__sync-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lanyard-accent);
  box-shadow: 0 0 8px var(--lanyard-accent-soft);
  animation: syncPulse 2.2s ease-in-out infinite;
}

.lanyard-card.is-offline .lanyard-card__sync-dot {
  background: var(--muted);
  box-shadow: none;
  animation: none;
}

@keyframes syncPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.lanyard-card__core {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: 0;
}

.lanyard-card__telemetry {
  padding: 1.35rem 1.25rem 1.5rem 1.35rem;
  border-right: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: color-mix(in srgb, var(--bg) 22%, transparent);
}

.lanyard-card__waveform {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 52px;
  padding: 0.35rem 0;
}

.lanyard-card__waveform span {
  flex: 1;
  min-width: 2px;
  height: 100%;
  background: color-mix(in srgb, var(--lanyard-accent) 55%, var(--line));
  border-radius: 1px;
  transform-origin: bottom;
  animation: waveBar 1.8s ease-in-out infinite;
  opacity: 0.55;
}

.lanyard-card__waveform span:nth-child(1) { animation-delay: 0s; }
.lanyard-card__waveform span:nth-child(2) { animation-delay: 0.08s; }
.lanyard-card__waveform span:nth-child(3) { animation-delay: 0.16s; }
.lanyard-card__waveform span:nth-child(4) { animation-delay: 0.24s; }
.lanyard-card__waveform span:nth-child(5) { animation-delay: 0.32s; }
.lanyard-card__waveform span:nth-child(6) { animation-delay: 0.4s; }
.lanyard-card__waveform span:nth-child(7) { animation-delay: 0.48s; }
.lanyard-card__waveform span:nth-child(8) { animation-delay: 0.56s; }
.lanyard-card__waveform span:nth-child(9) { animation-delay: 0.64s; }
.lanyard-card__waveform span:nth-child(10) { animation-delay: 0.72s; }
.lanyard-card__waveform span:nth-child(11) { animation-delay: 0.8s; }
.lanyard-card__waveform span:nth-child(12) { animation-delay: 0.88s; }
.lanyard-card__waveform span:nth-child(13) { animation-delay: 0.96s; }
.lanyard-card__waveform span:nth-child(14) { animation-delay: 1.04s; }
.lanyard-card__waveform span:nth-child(15) { animation-delay: 1.12s; }
.lanyard-card__waveform span:nth-child(16) { animation-delay: 0.04s; }
.lanyard-card__waveform span:nth-child(17) { animation-delay: 0.12s; }
.lanyard-card__waveform span:nth-child(18) { animation-delay: 0.2s; }
.lanyard-card__waveform span:nth-child(19) { animation-delay: 0.28s; }
.lanyard-card__waveform span:nth-child(20) { animation-delay: 0.36s; }

@keyframes waveBar {
  0%, 100% { transform: scaleY(0.35); opacity: 0.4; }
  50% { transform: scaleY(1); opacity: 0.85; }
}

.presence-stage.is-holding .lanyard-card__waveform span,
.presence-stage.is-pulsed .lanyard-card__waveform span {
  animation-duration: 0.55s;
  background: var(--lanyard-accent);
  opacity: 0.9;
}

.presence-stage.is-holding .lanyard-card__scan,
.presence-stage.is-pulsed .lanyard-card__scan {
  animation-duration: 1.4s;
  opacity: 0.75;
}

.lanyard-card__metrics {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.lanyard-card__metrics li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
}

.lanyard-card__metrics li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.lanyard-card__metric-key {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.lanyard-card__metric-val {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--text);
  text-align: right;
}

.lanyard-card__identity {
  display: flex;
  align-items: flex-start;
  gap: 1.15rem;
  padding: 1.35rem 1.35rem 1.25rem 1.15rem;
}

.lanyard-card__avatar-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
}

.lanyard-card__avatar-frame {
  position: absolute;
  inset: -5px;
  border: 1px solid color-mix(in srgb, var(--lanyard-accent) 45%, transparent);
  border-radius: var(--radius, 2px);
  pointer-events: none;
  transition: border-color 0.35s ease, transform 0.4s ease;
}

.lanyard-card__avatar {
  position: relative;
  z-index: 1;
  width: 92px;
  height: 92px;
  border-radius: var(--radius, 2px);
  object-fit: cover;
  display: block;
  border: 1px solid var(--line);
  background: var(--surface);
  opacity: 0;
  transition: border-color 0.35s ease, box-shadow 0.35s ease, opacity 0.3s ease;
}

.lanyard-card__avatar.is-ready {
  opacity: 1;
}

.lanyard-card__avatar-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  z-index: 2;
  width: 14px;
  height: 14px;
  border-radius: var(--radius, 2px);
  border: 2px solid var(--surface);
  background: var(--muted);
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.lanyard-card.is-online .lanyard-card__avatar-badge {
  background: var(--accent, #00e8ff);
  box-shadow: 0 0 10px var(--accent-glow);
}

.lanyard-card.is-idle .lanyard-card__avatar-badge {
  background: var(--accent-blue, #4f7cff);
  box-shadow: 0 0 10px var(--accent-blue-soft);
}

.lanyard-card.is-dnd .lanyard-card__avatar-badge {
  background: var(--accent-red, #ff3b5c);
  box-shadow: 0 0 10px var(--accent-red-soft);
}

.lanyard-card.is-offline .lanyard-card__avatar-badge {
  background: #6d7684;
}

.presence-stage.is-holding .lanyard-card__avatar-frame,
.presence-stage.is-pulsed .lanyard-card__avatar-frame {
  transform: scale(1.04);
  border-color: var(--lanyard-accent);
}

.lanyard-card__body {
  min-width: 0;
  flex: 1;
  padding-top: 0.15rem;
}

.lanyard-card__title {
  font-family: var(--font-display, 'Instrument Serif', serif);
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.lanyard-card__handle {
  margin-top: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.lanyard-card__handle::before {
  content: '@';
  opacity: 0.5;
}

.lanyard-card__activity {
  margin-top: 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: var(--radius, 2px);
  background: color-mix(in srgb, var(--bg) 30%, transparent);
}

.lanyard-card__activity-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lanyard-accent);
  margin-bottom: 0.4rem;
}

.lanyard-card__subtitle {
  margin: 0;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.88;
}

.lanyard-card__kv {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.lanyard-card__foot {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 1.35rem 0.8rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  background: color-mix(in srgb, var(--bg) 28%, transparent);
}

.lanyard-card__foot-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--lanyard-accent), transparent);
  opacity: 0.35;
}

.lanyard-card__foot-meta {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.lanyard-card__status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius, 2px);
  background: currentColor;
  flex: 0 0 auto;
  animation: statusPulse 2.4s ease-in-out infinite;
}

.lanyard-card.is-online .lanyard-card__status-dot { color: var(--accent, #00e8ff); }
.lanyard-card.is-idle .lanyard-card__status-dot { color: var(--accent-blue, #4f7cff); }
.lanyard-card.is-dnd .lanyard-card__status-dot { color: var(--accent-red, #ff3b5c); }
.lanyard-card.is-offline .lanyard-card__status-dot { color: #6d7684; }

.lanyard-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius, 2px);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: border-color 0.3s ease, color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.lanyard-chip[data-lanyard-status="online"] {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.lanyard-chip[data-lanyard-status="idle"] {
  border-color: color-mix(in srgb, var(--accent-blue) 45%, transparent);
  color: var(--accent-blue);
}

.lanyard-chip[data-lanyard-status="dnd"] {
  border-color: color-mix(in srgb, var(--accent-red) 45%, transparent);
  color: var(--accent-red);
}

.lanyard-chip[data-lanyard-status="offline"] {
  border-color: var(--line);
  color: var(--muted);
}

.lanyard-kv-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.28rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: var(--radius, 2px);
  background: color-mix(in srgb, var(--bg) 25%, transparent);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lanyard-kv-chip__key {
  color: var(--muted);
  opacity: 0.7;
}

.lanyard-kv-chip__value {
  color: var(--text);
  opacity: 0.9;
}

.lanyard-card__spotify {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-top: 0.85rem;
  padding: 0.65rem;
  border: 1px solid color-mix(in srgb, var(--lanyard-accent) 35%, var(--line));
  background: color-mix(in srgb, var(--bg) 40%, transparent);
}

.lanyard-card__spotify[hidden] {
  display: none;
}

.lanyard-card__album {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.lanyard-card__spotify-copy {
  min-width: 0;
  flex: 1;
}

.lanyard-card__track {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lanyard-card__progress {
  height: 3px;
  background: color-mix(in srgb, var(--line) 70%, transparent);
  overflow: hidden;
}

.lanyard-card__progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-red), var(--accent), var(--accent-blue));
  transform-origin: left center;
}

.lanyard-card.is-listening .lanyard-card__waveform span {
  animation-duration: 0.7s;
  background: var(--lanyard-accent);
}

.presence-stage:hover .lanyard-card {
  border-color: color-mix(in srgb, var(--lanyard-accent) 35%, var(--line));
}

.presence-stage.is-holding .lanyard-card,
.presence-stage.is-pulsed .lanyard-card {
  box-shadow: 0 0 28px var(--accent-glow);
}

.lanyard-card.is-connecting [data-lanyard-title] {
  color: var(--muted);
}

.lanyard-card.is-error [data-lanyard-subtitle] {
  color: var(--accent-red, #ff3b5c);
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.88); }
}

@media (max-width: 768px) {
  .presence-stage {
    padding: 3.25rem 0 calc(5.5rem + env(safe-area-inset-bottom, 0px));
    min-height: 0;
  }

  .presence-stage__hint {
    font-size: 0.54rem;
  }

  .lanyard-card {
    margin-top: 2rem;
  }

  .lanyard-card__core {
    grid-template-columns: 1fr;
  }

  .lanyard-card__telemetry {
    border-right: none;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
    padding: 1rem;
  }

  .lanyard-card__waveform {
    height: 40px;
  }

  .lanyard-card__identity {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }

  .lanyard-card__head {
    padding: 0.85rem 1rem;
    flex-wrap: wrap;
  }

  .lanyard-card__avatar-wrap,
  .lanyard-card__avatar {
    width: 76px;
    height: 76px;
  }

  .lanyard-card__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 1rem 0.75rem;
  }

  .lanyard-card__foot-line {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lanyard-card__waveform span,
  .lanyard-card__sync-dot,
  .lanyard-card__scan {
    animation: none;
  }
}

@media (pointer: coarse) {
  .presence-stage__hint {
    pointer-events: auto;
  }
}