/* GriGsi Instant — single-scene connect */

:root {
  --inst-indigo: #3d2860;
  --inst-deep: #050408;
  --inst-space-top: #0a0814;
  --inst-glow: #ffc64b;
  /* Lighter gold for text on dark bg — resists Samsung/Chrome forced-dark remapping */
  --inst-glow-text: #ffe08a;
  --inst-terracotta: #c4583a;
  --inst-terracotta-soft: #e09878;
  --inst-text: rgba(255, 255, 255, 0.92);
  --inst-muted: rgba(255, 255, 255, 0.55);
}

html {
  color-scheme: dark only;
}

html,
body.inst-page {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background-color: var(--inst-deep);
  background-image:
    radial-gradient(ellipse 85% 55% at 50% -8%, rgba(72, 52, 110, 0.38) 0%, transparent 58%),
    radial-gradient(ellipse 60% 45% at 92% 78%, rgba(40, 60, 100, 0.22) 0%, transparent 52%),
    radial-gradient(ellipse 50% 40% at 8% 88%, rgba(50, 38, 72, 0.18) 0%, transparent 48%),
    linear-gradient(180deg, var(--inst-space-top) 0%, var(--inst-deep) 42%, #020106 100%);
  color: var(--inst-text);
  -webkit-font-smoothing: antialiased;
  forced-color-adjust: none;
  -webkit-forced-color-adjust: none;
  position: relative;
}

/* Starfield — fixed behind all content */
body.inst-page::before,
body.inst-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body.inst-page::before {
  background-image:
    radial-gradient(1px 1px at 5% 8%, rgba(255, 255, 255, 0.82), transparent),
    radial-gradient(1px 1px at 12% 22%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 18% 41%, rgba(255, 248, 230, 0.6), transparent),
    radial-gradient(1px 1px at 24% 67%, rgba(255, 255, 255, 0.38), transparent),
    radial-gradient(1px 1px at 31% 15%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1px 1px at 37% 53%, rgba(255, 255, 255, 0.72), transparent),
    radial-gradient(1px 1px at 43% 84%, rgba(255, 255, 255, 0.42), transparent),
    radial-gradient(1px 1px at 49% 29%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 55% 61%, rgba(255, 240, 210, 0.58), transparent),
    radial-gradient(1px 1px at 61% 11%, rgba(255, 255, 255, 0.48), transparent),
    radial-gradient(1px 1px at 67% 38%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1px 1px at 73% 72%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 79% 19%, rgba(255, 255, 255, 0.52), transparent),
    radial-gradient(1px 1px at 85% 47%, rgba(255, 255, 255, 0.78), transparent),
    radial-gradient(1px 1px at 91% 88%, rgba(255, 255, 255, 0.36), transparent),
    radial-gradient(1px 1px at 97% 33%, rgba(255, 255, 255, 0.44), transparent),
    radial-gradient(1px 1px at 8% 58%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 15% 91%, rgba(255, 255, 255, 0.32), transparent),
    radial-gradient(1px 1px at 22% 76%, rgba(255, 255, 255, 0.62), transparent),
    radial-gradient(1px 1px at 28% 5%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 35% 95%, rgba(255, 255, 255, 0.28), transparent),
    radial-gradient(1px 1px at 52% 8%, rgba(255, 255, 255, 0.46), transparent),
    radial-gradient(1px 1px at 58% 93%, rgba(255, 255, 255, 0.34), transparent),
    radial-gradient(1px 1px at 64% 56%, rgba(255, 255, 255, 0.56), transparent),
    radial-gradient(1px 1px at 71% 26%, rgba(255, 255, 255, 0.42), transparent),
    radial-gradient(1px 1px at 77% 64%, rgba(255, 255, 255, 0.68), transparent),
    radial-gradient(1px 1px at 83% 3%, rgba(255, 255, 255, 0.38), transparent),
    radial-gradient(1px 1px at 89% 56%, rgba(255, 255, 255, 0.48), transparent),
    radial-gradient(1px 1px at 95% 71%, rgba(255, 255, 255, 0.58), transparent),
    radial-gradient(1px 1px at 3% 35%, rgba(255, 255, 255, 0.52), transparent),
    radial-gradient(1px 1px at 46% 44%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1px 1px at 92% 42%, rgba(255, 255, 255, 0.36), transparent),
    radial-gradient(1.5px 1.5px at 10% 48%, rgba(255, 255, 255, 0.88), transparent),
    radial-gradient(1.5px 1.5px at 26% 18%, rgba(255, 248, 220, 0.75), transparent),
    radial-gradient(1.5px 1.5px at 44% 78%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 62% 42%, rgba(255, 255, 255, 0.82), transparent),
    radial-gradient(1.5px 1.5px at 78% 12%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1.5px 1.5px at 88% 62%, rgba(255, 240, 200, 0.72), transparent),
    radial-gradient(2px 2px at 20% 62%, rgba(255, 255, 255, 0.92), transparent),
    radial-gradient(2px 2px at 54% 24%, rgba(255, 252, 240, 0.85), transparent),
    radial-gradient(2px 2px at 70% 82%, rgba(255, 255, 255, 0.78), transparent),
    radial-gradient(2.5px 2.5px at 36% 32%, rgba(255, 255, 255, 0.95), transparent),
    radial-gradient(2.5px 2.5px at 82% 36%, rgba(255, 248, 230, 0.88), transparent),
    radial-gradient(3px 3px at 14% 82%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(3px 3px at 58% 68%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(3.5px 3.5px at 48% 52%, rgba(255, 255, 255, 0.42), transparent);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

body.inst-page::after {
  opacity: 0.55;
  background-image:
    radial-gradient(1px 1px at 7% 28%, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(1px 1px at 33% 62%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 56% 18%, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1px 1px at 74% 48%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1px 1px at 91% 22%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(2px 2px at 16% 72%, rgba(255, 255, 255, 0.75), transparent),
    radial-gradient(2px 2px at 42% 8%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(2px 2px at 68% 58%, rgba(255, 255, 255, 0.82), transparent),
    radial-gradient(2.5px 2.5px at 86% 78%, rgba(255, 248, 220, 0.6), transparent);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  animation: inst-stars-twinkle 9s ease-in-out infinite alternate;
}

@keyframes inst-stars-twinkle {
  0% {
    opacity: 0.38;
  }
  100% {
    opacity: 0.72;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.inst-page::after {
    animation: none;
    opacity: 0.55;
  }
}

.inst-site-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: max(8px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}

.inst-site-logo {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--inst-glow);
  -webkit-text-fill-color: var(--inst-glow);
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(255, 198, 75, 0.25);
}

.inst-site-logo:hover,
.inst-site-logo:focus-visible {
  color: var(--inst-glow-text);
  -webkit-text-fill-color: var(--inst-glow-text);
}

.inst {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: max(68px, calc(env(safe-area-inset-top) + 52px)) 0 max(28px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  forced-color-adjust: none;
  -webkit-forced-color-adjust: none;
}

.inst-scene {
  width: min(420px, 100%);
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  text-align: left;
  animation: inst-fade-in 0.35s ease;
}

.inst-scene--idle {
  gap: 14px;
}

.inst-join-block {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  align-self: stretch;
}

.inst-join-block .inst-join__lead {
  text-align: center;
  margin: 0 0 2px;
}

.inst-scene.hidden {
  display: none !important;
}

@keyframes inst-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.inst-brand {
  margin: 0 0 2px 4px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--inst-muted);
}

/* Mode reel — slide + scale · orbs drift and lightly touch */
.inst-reel-wrap {
  width: 100%;
  align-self: center;
  text-align: center;
  margin-bottom: 8px;
}

.inst-reel {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.inst-reel__stage {
  position: relative;
  width: 100%;
  min-height: min(280px, 54vw);
  margin: 0 auto;
}

.inst-reel__orb {
  position: absolute;
  top: 50%;
  width: min(248px, 46vw);
  height: min(248px, 46vw);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition:
    left 0.52s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    filter 0.4s ease;
  transform: translate(-50%, -50%) scale(0.76);
  opacity: 0.52;
  filter: saturate(0.82);
  z-index: 1;
  animation: inst-orb-breathe 4.2s ease-in-out infinite;
}

.inst-reel__orb.is-active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  filter: none;
  z-index: 2;
  animation: inst-orb-float 3.4s ease-in-out infinite;
}

/* Connect active — gold orb leads, teal peeks from the right */
.inst-reel[data-mode="connect"] .inst-reel__orb--connect {
  left: calc(50% - 6px);
}

.inst-reel[data-mode="connect"] .inst-reel__orb--find {
  left: calc(50% + 108px);
}

/* Find active — slide left, teal orb leads */
.inst-reel[data-mode="find"] .inst-reel__orb--connect {
  left: calc(50% - 108px);
}

.inst-reel[data-mode="find"] .inst-reel__orb--find {
  left: calc(50% + 6px);
}

@keyframes inst-orb-float {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, calc(-50% - 6px)) scale(1.02);
  }
}

@keyframes inst-orb-breathe {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.76);
  }
  50% {
    transform: translate(-50%, calc(-50% - 4px)) scale(0.8);
  }
}

@media (max-width: 380px) {
  .inst-reel__stage {
    min-height: min(252px, 58vw);
  }

  .inst-reel__orb {
    width: min(220px, 44vw);
    height: min(220px, 44vw);
  }

  .inst-reel[data-mode="connect"] .inst-reel__orb--find {
    left: calc(50% + 92px);
  }

  .inst-reel[data-mode="find"] .inst-reel__orb--connect {
    left: calc(50% - 92px);
  }
}

.inst-reel__orb:focus-visible {
  outline: 2px solid var(--inst-glow);
  outline-offset: 5px;
  border-radius: 50%;
}

.inst-reel__ring,
.inst-reel__core,
.inst-reel__pulse {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.inst-reel__ring,
.inst-reel__pulse {
  inset: 0;
}

.inst-reel__core {
  inset: 18%;
}

/* Connect — GriGsi gold sphere */
.inst-reel__orb--connect .inst-reel__core {
  background: radial-gradient(
    circle at 34% 26%,
    #ffffff 0%,
    #fff6d4 14%,
    #ffc64b 38%,
    #f5a623 68%,
    #d48806 100%
  );
  box-shadow:
    0 0 42px rgba(255, 198, 75, 0.52),
    0 12px 32px rgba(0, 0, 0, 0.3),
    inset 0 5px 14px rgba(255, 255, 255, 0.5),
    inset 0 -8px 16px rgba(180, 120, 0, 0.28);
}

.inst-reel__orb--connect .inst-reel__ring {
  border: 2px solid rgba(255, 224, 138, 0.45);
  animation: inst-pulse 2.5s ease-in-out infinite;
}

.inst-reel__orb--connect .inst-reel__pulse {
  inset: -8%;
  border: 1px solid rgba(255, 198, 75, 0.28);
  animation: inst-scan 2.8s ease-in-out infinite;
}

.inst-reel__orb--connect .inst-reel__label {
  color: #1a1528;
  -webkit-text-fill-color: #1a1528;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
  text-shadow: none;
  padding: 0 8px;
  text-align: center;
  line-height: 1.15;
}

/* Find Som — teal radar sphere */
.inst-reel__orb--find .inst-reel__core {
  background: radial-gradient(
    circle at 35% 28%,
    #ffffff 0%,
    #c8f5e8 18%,
    #2ea082 52%,
    #1a5c4a 88%
  );
  box-shadow:
    0 0 28px rgba(46, 160, 130, 0.4),
    0 8px 22px rgba(0, 0, 0, 0.28),
    inset 0 4px 10px rgba(255, 255, 255, 0.35),
    inset 0 -6px 12px rgba(26, 92, 74, 0.32);
}

.inst-reel__orb--find .inst-reel__ring {
  border: 2px solid rgba(184, 240, 223, 0.4);
  animation: inst-pulse 3s ease-in-out infinite;
}

.inst-reel__orb--find .inst-reel__label {
  color: #fff;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  padding: 0 6px;
  text-align: center;
  line-height: 1.15;
}

@media (max-width: 380px) {
  .inst-reel__orb--connect .inst-reel__label {
    font-size: 1.22rem;
  }

  .inst-reel__orb--find .inst-reel__label {
    font-size: 0.98rem;
  }
}

.inst-reel__orb--busy .inst-reel__ring,
.inst-reel__orb--busy .inst-reel__pulse {
  animation: inst-pulse-fast 0.9s ease-in-out infinite;
}

.inst-reel__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.inst-reel__dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
}

.inst-reel__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: transform 0.25s ease, background 0.25s ease;
}

.inst-reel__dot.is-on {
  background: var(--inst-glow);
  transform: scale(1.25);
}

.inst-reel__dot[data-for="find"].is-on {
  background: #2ea082;
}

@keyframes inst-scan {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.25;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.7;
  }
}

@keyframes inst-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@keyframes inst-pulse-fast {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

.inst-ghost {
  border: none;
  background: transparent;
  color: var(--inst-muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
}

.inst-ghost:hover,
.inst-ghost:focus-visible {
  color: var(--inst-text);
}

.inst-recent-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}

.inst-recent-row .inst-recent {
  flex: 1;
  min-width: 0;
}

.inst-recent-more {
  flex: 0 0 auto;
  align-self: center;
  white-space: nowrap;
}

.inst-recent {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.inst-recent__code {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}

/* Ready scene */
.inst-join__lead {
  margin: 0;
  font-size: 0.95rem;
  color: var(--inst-terracotta-soft);
  -webkit-text-fill-color: var(--inst-terracotta-soft);
  font-weight: 600;
}

.inst-code {
  font-size: clamp(1.35rem, 6vw, 1.85rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.35;
  word-break: break-all;
  color: var(--inst-glow-text);
  -webkit-text-fill-color: var(--inst-glow-text);
  text-shadow: 0 0 18px rgba(255, 224, 138, 0.28);
  min-height: 2.6em;
}

.inst-code .inst-digit {
  display: inline-block;
  color: inherit;
  -webkit-text-fill-color: inherit;
  opacity: 0;
  transform: translateY(6px);
  animation: inst-digit-in 0.28s ease forwards;
}

@keyframes inst-digit-in {
  to {
    opacity: 1;
    transform: none;
  }
}

.inst-qr {
  padding: 12px;
  background: #fff;
  border-radius: 12px;
  line-height: 0;
}

.inst-qr img,
.inst-qr canvas {
  display: block;
  max-width: 180px;
  height: auto;
}

.inst-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.inst-actions--row {
  width: 100%;
}

.inst-join-block .inst-actions {
  max-width: 320px;
  align-self: center;
}

.inst-join-block .inst-actions .inst-chip {
  flex: 1 1 0;
  min-width: 0;
}

.inst-chip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--inst-text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.inst-chip:hover,
.inst-chip:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.inst-chip--wide {
  width: 100%;
  max-width: 320px;
}

.inst-primary {
  width: 100%;
  max-width: 320px;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  background-color: var(--inst-glow);
  background: linear-gradient(145deg, #ffc64b, #e6a800);
  color: #1a1a24;
  -webkit-text-fill-color: #1a1a24;
  forced-color-adjust: none;
  -webkit-forced-color-adjust: none;
  box-shadow: 0 8px 24px rgba(255, 198, 75, 0.35);
}

.inst-primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.inst-primary--pulse {
  animation: inst-continue-pulse 2.2s ease-in-out infinite;
}

@keyframes inst-continue-pulse {
  0%,
  100% {
    box-shadow: 0 8px 24px rgba(255, 198, 75, 0.35);
  }
  50% {
    box-shadow: 0 10px 32px rgba(255, 198, 75, 0.55);
  }
}

/* Connected */
.inst-participants {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 56px;
}

.inst-participant-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.inst-participant-dot.is-you {
  background-color: var(--inst-glow);
  background: var(--inst-glow);
  border-color: rgba(255, 198, 75, 0.7);
  box-shadow: 0 0 16px rgba(255, 198, 75, 0.45);
  forced-color-adjust: none;
  -webkit-forced-color-adjust: none;
}

.inst-participant-dot.is-other {
  background: #fff;
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.35);
  animation: inst-other-glow 2s ease-in-out infinite;
}

@keyframes inst-other-glow {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.92;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

.inst-connected-code {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--inst-muted);
  word-break: break-all;
}

/* Join */
.inst-join-field {
  display: flex;
  width: 100%;
  max-width: 360px;
  gap: 8px;
}

.inst-join-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25);
  color: var(--inst-text);
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 600;
}

.inst-join-input::placeholder {
  color: rgba(255, 255, 255, 0.36);
  -webkit-text-fill-color: rgba(255, 255, 255, 0.36);
  font-weight: 500;
}

.inst-join-input:-webkit-autofill,
.inst-join-input:-webkit-autofill:hover,
.inst-join-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--inst-text);
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.25) inset;
  transition: background-color 99999s ease-out 0s;
}

.inst-join-input:focus {
  outline: 2px solid rgba(255, 198, 75, 0.55);
  border-color: transparent;
}

.inst-join-input::-webkit-search-cancel-button,
.inst-join-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.inst-join-go {
  flex: 0 0 auto;
  height: 48px;
  min-width: 56px;
  border: none;
  border-radius: 12px;
  background-color: var(--inst-glow);
  background: var(--inst-glow);
  color: #1a1a24;
  -webkit-text-fill-color: #1a1a24;
  font-weight: 800;
  cursor: pointer;
  padding: 0 16px;
  forced-color-adjust: none;
  -webkit-forced-color-adjust: none;
}

.inst-error {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(180, 40, 40, 0.92);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  z-index: 50;
}

.inst-toast {
  position: fixed;
  left: 50%;
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 40px));
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(30, 20, 50, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.86rem;
  font-weight: 600;
  z-index: 60;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.inst-toast.show {
  opacity: 1;
  transform: translateX(-50%);
}

.inst-toast.hidden {
  display: block;
}

/* QR scan modal (shared ids with connect-qr-scan.js) */
.inst-modal[hidden] {
  display: none !important;
}

.inst-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.inst-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.inst-modal__panel {
  position: relative;
  width: min(400px, 100%);
  background: #1e1435;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.inst-modal__panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.inst-modal__panel video {
  width: 100%;
  border-radius: 10px;
  background: #000;
  max-height: 50vh;
  object-fit: cover;
}

body.cn-scan-open,
body.inst-modal-open {
  overflow: hidden;
}

.inst-modal__panel--show-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.inst-show-qr__lead {
  margin: 0;
  font-size: 0.86rem;
  color: var(--inst-muted);
}

.inst-show-qr__code {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--inst-glow-text);
  word-break: break-all;
}

.inst-show-qr__host {
  margin: 4px auto 6px;
}

.inst-modal__panel--show-qr .inst-primary {
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

.inst-pins-row,
.inst-join-block,
.inst-register-panel,
.inst-recent-row {
  align-self: stretch;
  width: 100%;
}

.inst-pins-row {
  max-width: 360px;
  margin-top: 4px;
}

.inst-recent-row {
  max-width: 360px;
}

.inst-pins__lead {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--inst-muted);
  text-align: center;
}

.inst-pins {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.inst-pin {
  border: 1px solid rgba(46, 160, 130, 0.45);
  background: rgba(46, 160, 130, 0.14);
  color: #dff7ef;
  font: 600 0.8rem/1.2 Inter, system-ui, sans-serif;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
}

.inst-pin:hover,
.inst-pin:focus-visible {
  border-color: rgba(46, 160, 130, 0.75);
  background: rgba(46, 160, 130, 0.22);
}

.inst-pin small {
  display: block;
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.75;
}

.inst-find-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 360px;
}

.inst-find-form__go {
  width: 100%;
  height: 48px;
  margin-top: 2px;
}

.inst-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.inst-field__label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--inst-terracotta-soft);
  -webkit-text-fill-color: var(--inst-terracotta-soft);
}

.inst-field__input {
  width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.25);
  color: var(--inst-text);
  font: 500 0.92rem/1.2 Inter, system-ui, sans-serif;
}

.inst-field__input::placeholder {
  color: rgba(255, 255, 255, 0.34);
  -webkit-text-fill-color: rgba(255, 255, 255, 0.34);
  font-weight: 500;
}

.inst-field__input:-webkit-autofill,
.inst-field__input:-webkit-autofill:hover,
.inst-field__input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--inst-text);
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.25) inset;
  transition: background-color 99999s ease-out 0s;
}

.inst-field__input:focus {
  outline: 2px solid rgba(224, 152, 120, 0.45);
  border-color: transparent;
}

.inst-field__input::-webkit-search-cancel-button,
.inst-field__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.inst-register-panel {
  width: 100%;
  max-width: 360px;
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 198, 75, 0.35);
  background: rgba(255, 198, 75, 0.08);
}

.inst-register__lead {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--inst-muted);
  text-align: center;
}

.inst-register__input {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(126, 123, 155, 0.35);
  background: rgba(0, 0, 0, 0.2);
  color: var(--inst-text);
  font: 500 0.85rem/1.2 Inter, system-ui, sans-serif;
}

.inst-register__hint {
  margin: 0 0 8px;
  font-size: 0.75rem;
  color: var(--inst-muted);
  text-align: center;
  min-height: 1em;
}

.inst-register__btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffc64b, #e8a820);
  color: #1a1528;
  font: 700 0.9rem/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.inst-register__btn--buy {
  margin-bottom: 8px;
  background: transparent;
  border: 1px solid rgba(255, 198, 75, 0.55);
  color: #ffc64b;
}

.inst-actions.hidden {
  display: none;
}

