/* ==========================================================================
   Crossid — shared styles for the landing page, dashboard and legal pages.

   Design idea: Crossid is about connections, so the one memorable element is
   the "link graph" — Minecraft, Discord and Roblox tiles joined by wires that
   are solid when linked and dashed when not. Everything else stays quiet.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  /* Surfaces: a deep indigo night, not a neutral black. */
  --ink: #13152a;
  --deck: #1b1e36;
  --deck-2: #23274a;
  --rail: #2e3358;
  --rail-soft: #252948;

  /* Text */
  --chalk: #eceefb;
  --haze: #9a9ec4;
  --dim: #6f7398;

  /* Platforms — used for the graph and nothing decorative. */
  --mc: #6cc24a;
  --dc: #7c86ff;
  --rb: #e9eaf7;

  /* Actions and states */
  --accent: #7c86ff;
  --accent-strong: #6670f5;
  --ok: #4fd18b;
  --warn: #f2b84b;
  --bad: #f26d6d;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --max: 1120px;
  --gutter: max(16px, calc((100% - var(--max)) / 2));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  /* Reserve the scrollbar's space so pages of different lengths don't shift. */
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--chalk);
  font: 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}

body > main,
body > section {
  flex: 1 0 auto;
}

h1,
h2,
h3 {
  font-family: var(--display);
  line-height: 1.12;
  margin: 0;
  letter-spacing: -0.015em;
}

h1 {
  font-size: clamp(1.8rem, 1.3rem + 2vw, 2.5rem);
  font-weight: 750;
}

h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

h3 {
  font-size: 1.05rem;
  font-weight: 650;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: var(--mono);
  font-size: 0.86em;
}

code {
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: var(--deck-2);
  color: var(--chalk);
}

pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--rail);
  border-radius: var(--r-md);
  background: #0f1124;
  line-height: 1.6;
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: rgba(124, 134, 255, 0.35);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--haze);
}

.container {
  width: 100%;
  padding-inline: var(--gutter);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.spacer {
  flex: 1;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  padding: 0.6rem var(--gutter);
  background: rgba(19, 21, 42, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rail-soft);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--chalk);
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-link:hover {
  text-decoration: none;
}

.logo {
  width: 26px;
  height: 26px;
  flex: none;
}

.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.3rem;
}

.topnav a:not(.btn) {
  color: var(--haze);
  font-size: 0.92rem;
}

.topnav a:not(.btn):hover {
  color: var(--chalk);
  text-decoration: none;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.25rem 0.7rem 0.25rem 0.25rem;
  border-radius: 999px;
  background: var(--deck);
}

.user-chip img,
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--deck-2);
  object-fit: cover;
}

.user-chip span {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.switcher select {
  max-width: 220px;
}

@media (max-width: 720px) {
  .topnav a:not(.btn) {
    display: none;
  }
  .user-chip span {
    display: none;
  }
  .user-chip {
    padding: 0.2rem;
  }
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.55rem 1.05rem;
  border: 1px solid var(--rail);
  border-radius: var(--r-sm);
  background: var(--deck-2);
  color: var(--chalk);
  font: 600 0.92rem/1.2 var(--body);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: var(--haze);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary,
.btn.discord {
  border-color: transparent;
  background: var(--accent-strong);
  color: #fff;
}

.btn.primary:hover,
.btn.discord:hover {
  background: #5862ea;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--haze);
}

.btn.ghost:hover {
  background: var(--deck);
  color: var(--chalk);
}

.btn.danger {
  background: transparent;
  border-color: rgba(242, 109, 109, 0.45);
  color: var(--bad);
}

.btn.danger:hover {
  background: rgba(242, 109, 109, 0.12);
  border-color: var(--bad);
}

.btn.small {
  min-height: 34px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn.block {
  width: 100%;
}

.btn.large {
  min-height: 48px;
  padding: 0.7rem 1.4rem;
  font-size: 1rem;
}

/* ------------------------------------------------------------ badges/chips */

.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--deck-2);
  color: var(--haze);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok,
.chip.on {
  background: rgba(79, 209, 139, 0.13);
  color: var(--ok);
}

.badge.warn {
  background: rgba(242, 184, 75, 0.13);
  color: var(--warn);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ------------------------------------------------------------------- forms */

.form {
  display: grid;
  gap: 0.9rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--haze);
  font-size: 0.85rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rail);
  border-radius: var(--r-sm);
  background: #101227;
  color: var(--chalk);
  font: 0.94rem var(--body);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 134, 255, 0.22);
}

.error {
  color: var(--bad);
  font-size: 0.88rem;
}

.copy-field {
  display: flex;
  gap: 0.5rem;
}

.copy-field input {
  font-family: var(--mono);
  font-size: 0.86rem;
}

.callout {
  padding: 0.75rem 0.95rem;
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--deck-2);
  font-size: 0.92rem;
}

.callout.warn {
  border-left-color: var(--warn);
}

/* -------------------------------------------------------------- link graph */

.graph {
  --tile: 76px;
  display: grid;
  grid-template-columns: 1fr minmax(28px, 1.1fr) 1fr minmax(28px, 1.1fr) 1fr;
  align-items: start;
}

.node {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  min-width: 0;
  text-align: center;
}

.tile {
  display: grid;
  place-items: center;
  width: var(--tile);
  height: var(--tile);
  border-radius: 22px;
  border: 2px dashed var(--rail);
  background: var(--deck);
  color: var(--dim);
  transition: border-color 0.3s, background-color 0.3s, color 0.3s;
}

.tile svg {
  width: 46%;
  height: 46%;
}

.tile img {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  object-fit: cover;
}

.node.is-linked .tile {
  border-style: solid;
}

.node.mc.is-linked .tile {
  border-color: var(--mc);
  background: rgba(108, 194, 74, 0.1);
}

.node.dc .tile {
  border-style: solid;
  border-color: var(--dc);
  background: rgba(124, 134, 255, 0.12);
  color: var(--dc);
}

.node.rb.is-linked .tile {
  border-color: var(--rb);
  background: rgba(233, 234, 247, 0.08);
  color: var(--rb);
}

/* Minecraft glyph keeps its colours even when unlinked, just faded. */
.node.mc:not(.is-linked) .tile svg {
  opacity: 0.45;
  filter: grayscale(0.7);
}

.node-label {
  margin-top: 0.35rem;
  font-family: var(--display);
  font-weight: 650;
  font-size: 1rem;
}

.node-meta {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--haze);
  font-size: 0.84rem;
}

.node.is-linked .node-meta {
  color: var(--chalk);
}

.node-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.wire {
  height: 3px;
  margin-top: calc(var(--tile) / 2 - 1.5px);
  background: repeating-linear-gradient(
    90deg,
    var(--rail) 0 8px,
    transparent 8px 14px
  );
  transform-origin: left center;
}

.wire.is-linked.mc {
  background: linear-gradient(90deg, var(--mc), var(--dc));
}

.wire.is-linked.rb {
  background: linear-gradient(90deg, var(--dc), var(--rb));
}

@media (max-width: 560px) {
  .graph {
    --tile: 58px;
  }
  .tile {
    border-radius: 17px;
  }
  .node-label {
    font-size: 0.92rem;
  }
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 0.7rem 1.1rem;
  border-radius: var(--r-md);
  background: var(--chalk);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  transform: translateX(-50%);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease-out;
}

.toast.err {
  background: var(--bad);
  color: #fff;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ------------------------------------------------------------------ modal */

.modal {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--rail);
  border-radius: var(--r-lg);
  background: var(--deck);
  color: var(--chalk);
}

.modal::backdrop {
  background: rgba(8, 9, 20, 0.7);
}

.modal-body {
  display: grid;
  gap: 0.8rem;
  padding: 1.5rem;
}

.modal-body p {
  color: var(--haze);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* ----------------------------------------------------------------- footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 4rem;
  padding: 1.6rem var(--gutter);
  border-top: 1px solid var(--rail-soft);
  color: var(--dim);
  font-size: 0.86rem;
}

.footer-links {
  display: flex;
  gap: 1.2rem;
}

.footer-links a {
  color: var(--haze);
}

/* ==========================================================================
   Landing
   ========================================================================== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: 3rem;
  padding-block: clamp(3rem, 8vw, 6.5rem) clamp(2.5rem, 6vw, 5rem);
}

.hero h1 {
  font-size: clamp(2.5rem, 1.6rem + 4vw, 4.4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.035em;
}

.lede {
  max-width: 34rem;
  margin-top: 1.3rem;
  color: var(--haze);
  font-size: 1.1rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 2rem;
}

.hero-graph {
  padding: 2.2rem 1.4rem 1.8rem;
  border: 1px solid var(--rail-soft);
  border-radius: 28px;
  background: var(--deck);
}

.hero-graph .graph {
  --tile: 84px;
}

.hero-graph .caption {
  margin-top: 1.6rem;
  color: var(--haze);
  font-size: 0.88rem;
  text-align: center;
}

/* The one orchestrated moment: wires draw in, then the far tiles light up. */
@media (prefers-reduced-motion: no-preference) {
  .hero-graph .wire.is-linked {
    animation: wire-draw 0.7s cubic-bezier(0.3, 0.7, 0.2, 1) both;
  }
  .hero-graph .wire.rb {
    animation-delay: 0.55s;
    transform-origin: left center;
  }
  .hero-graph .wire.mc {
    animation-delay: 0.25s;
    transform-origin: right center;
  }
  .hero-graph .node.mc .tile {
    animation: tile-on 0.4s ease-out 0.85s both;
  }
  .hero-graph .node.rb .tile {
    animation: tile-on 0.4s ease-out 1.15s both;
  }
}

@keyframes wire-draw {
  from {
    transform: scaleX(0);
  }
}

@keyframes tile-on {
  from {
    border-style: dashed;
    border-color: var(--rail);
    background: var(--deck);
  }
}

.section {
  padding-block: clamp(3rem, 7vw, 5.5rem);
}

.section + .section {
  border-top: 1px solid var(--rail-soft);
}

.section-head {
  max-width: 40rem;
  margin-bottom: 2.4rem;
}

.section-head h2 {
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem);
  font-weight: 750;
}

.section-head p {
  margin-top: 0.7rem;
  color: var(--haze);
  font-size: 1.02rem;
}

/* Player steps: a real sequence, so they are numbered. */
.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  padding-top: 1.1rem;
  border-top: 2px solid var(--rail);
}

.steps li::before {
  content: counter(step);
  display: block;
  margin-bottom: 0.8rem;
  color: var(--accent);
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.steps h3 {
  margin-bottom: 0.45rem;
}

.steps p {
  color: var(--haze);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

.points {
  display: grid;
  gap: 1.4rem;
  margin: 0;
}

.points dt {
  font-family: var(--display);
  font-weight: 650;
  font-size: 1.05rem;
}

.points dd {
  margin: 0.3rem 0 0;
  color: var(--haze);
}

.share-demo {
  display: grid;
  gap: 0.5rem;
  padding: 1.2rem;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-lg);
  background: var(--deck);
}

.share-demo .demo-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--r-md);
  background: var(--ink);
}

.share-demo .demo-row .who {
  flex: 1;
  min-width: 0;
}

.share-demo .demo-row .who small {
  display: block;
  color: var(--haze);
  font-size: 0.8rem;
}

.commands {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--rail-soft);
}

.commands > div {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rail-soft);
}

.commands dt code {
  font-size: 0.9rem;
}

.commands dd {
  margin: 0;
  color: var(--haze);
}

.closing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.closing h2 {
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem);
  font-weight: 750;
}

.closing p {
  margin-top: 0.5rem;
  color: var(--haze);
}

@media (max-width: 880px) {
  .hero,
  .split {
    grid-template-columns: 1fr;
  }
  .steps {
    grid-template-columns: 1fr;
    gap: 1.6rem;
  }
}

@media (max-width: 560px) {
  .hero-graph {
    padding: 1.6rem 0.8rem 1.4rem;
  }
  .hero-graph .graph {
    --tile: 60px;
  }
  .commands > div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.page {
  width: 100%;
  padding: 2.4rem var(--gutter) 0;
}

.page-head {
  margin-bottom: 2rem;
}

.page-head p {
  margin-top: 0.4rem;
  color: var(--haze);
}

.block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.block-head p {
  color: var(--haze);
  font-size: 0.9rem;
}

/* ----------------------------------------------------------------- sign-in */

.auth-shell {
  display: grid;
  place-items: center;
  padding: 3.5rem 16px;
}

.auth-card {
  width: min(420px, 100%);
}

.auth-card .graph {
  --tile: 54px;
  margin-bottom: 2rem;
}

.auth-card .tile {
  border-radius: 16px;
}

.auth-card h1 {
  text-align: center;
}

.auth-card > p {
  margin: 0.6rem 0 1.6rem;
  color: var(--haze);
  text-align: center;
}

.key-login {
  margin-top: 1.4rem;
  border-top: 1px solid var(--rail-soft);
  padding-top: 1rem;
}

.key-login summary {
  color: var(--haze);
  font-size: 0.9rem;
  cursor: pointer;
}

.key-login summary:hover {
  color: var(--chalk);
}

.key-login .form {
  margin-top: 1rem;
}

.hint {
  margin-top: 1.4rem;
  color: var(--dim);
  font-size: 0.84rem;
  text-align: center;
}

/* -------------------------------------------------------------------- home */

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

@media (max-width: 880px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
}

/* Rows used for servers and communities — a list, not a wall of cards. */
.list {
  display: grid;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-lg);
  background: var(--deck);
  overflow: hidden;
}

.list:empty {
  display: none;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 64px;
  padding: 0.75rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--rail-soft);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.list-row:last-child {
  border-bottom: 0;
}

button.list-row {
  cursor: pointer;
}

button.list-row:hover {
  background: var(--deck-2);
}

.list-row .grow {
  flex: 1;
  min-width: 0;
}

.list-row .title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.list-row .sub {
  display: block;
  margin-top: 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--haze);
  font-size: 0.84rem;
}

.list-row .chev {
  color: var(--dim);
  font-size: 1.2rem;
}

.initial {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--deck-2);
  color: var(--chalk);
  font-family: var(--display);
  font-weight: 750;
  font-size: 1.05rem;
}

.identity-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 1rem;
  padding: 1.2rem;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-lg);
  background: var(--deck);
}

.identity-summary .graph {
  --tile: 46px;
  flex: 1 1 260px;
}

.identity-summary .tile {
  border-radius: 13px;
}

.identity-summary .node-label {
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.add-server {
  margin-top: 1rem;
  padding: 1.2rem;
  border: 1px dashed var(--rail);
  border-radius: var(--r-lg);
  color: var(--haze);
  font-size: 0.9rem;
}

.add-server strong {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--chalk);
  font-family: var(--display);
  font-size: 1.02rem;
}

.add-server .row {
  margin-top: 1rem;
}

/* -------------------------------------------------------------- my account */

.account-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.6rem 0 2.2rem;
}

.account-head .avatar {
  width: 56px;
  height: 56px;
}

.account-head p {
  color: var(--haze);
}

.account-graph {
  padding: 2rem 1.2rem 1.6rem;
  border: 1px solid var(--rail-soft);
  border-radius: 24px;
  background: var(--deck);
}

.account-graph .graph {
  --tile: 88px;
  max-width: 760px;
  margin: 0 auto;
}

@media (max-width: 560px) {
  .account-graph {
    padding: 1.4rem 0.6rem;
  }
  .account-graph .graph {
    --tile: 60px;
  }
}

.account-section {
  margin-top: 2.6rem;
}

.community .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

@media (max-width: 640px) {
  .list-row.community {
    flex-wrap: wrap;
  }
  .community .actions {
    width: 100%;
    justify-content: flex-start;
    padding-left: calc(40px + 0.9rem);
  }
}

/* Sharing switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  background: none;
  padding: 0.2rem;
  color: var(--haze);
  font: 600 0.82rem var(--body);
  cursor: pointer;
}

.switch .track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--rail);
  transition: background-color 0.2s;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--chalk);
  transition: transform 0.2s;
}

.switch[aria-checked="true"] {
  color: var(--ok);
}

.switch[aria-checked="true"] .track {
  background: var(--ok);
}

.switch[aria-checked="true"] .track::after {
  transform: translateX(16px);
}

.switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.code-drawer {
  display: grid;
  gap: 0.7rem;
  padding: 1rem 1rem 1.1rem calc(40px + 1.9rem);
  border-bottom: 1px solid var(--rail-soft);
  background: var(--ink);
}

.code-drawer .code {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

@media (max-width: 640px) {
  .code-drawer {
    padding-left: 1rem;
  }
}

.danger-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.6rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(242, 109, 109, 0.25);
  border-radius: var(--r-lg);
}

.danger-zone p {
  color: var(--haze);
  font-size: 0.9rem;
}

.danger-zone strong {
  display: block;
  color: var(--chalk);
}

.empty {
  padding: 1.6rem 1rem;
  color: var(--haze);
  text-align: center;
  font-size: 0.92rem;
}

/* ------------------------------------------------------------- owner view */

.owner-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.owner-head .initial {
  width: 56px;
  height: 56px;
  border-radius: 15px;
  font-size: 1.5rem;
  background: var(--accent-strong);
  color: #fff;
}

.owner-head .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  color: var(--haze);
  font-size: 0.86rem;
}

.owner-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 2.2rem;
  align-items: start;
}

.side-nav {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 0.2rem;
}

.side-nav button {
  padding: 0.6rem 0.8rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--haze);
  font: 600 0.92rem var(--body);
  text-align: left;
  cursor: pointer;
}

.side-nav button:hover {
  background: var(--deck);
  color: var(--chalk);
}

.side-nav button.active {
  background: var(--deck-2);
  color: var(--chalk);
  box-shadow: inset 3px 0 0 var(--accent);
}

@media (max-width: 820px) {
  .owner-layout {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }
  .side-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--rail-soft);
  }
  .side-nav button {
    flex: none;
    border-radius: 0;
  }
  .side-nav button.active {
    background: transparent;
    box-shadow: inset 0 -2px 0 var(--accent);
  }
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1.6rem;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-lg);
  background: var(--deck);
}

.stat {
  padding: 1.1rem 1.2rem;
}

.stat + .stat {
  border-left: 1px solid var(--rail-soft);
}

.stat .value {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 750;
  line-height: 1.1;
}

.stat .label {
  color: var(--chalk);
  font-weight: 600;
  font-size: 0.9rem;
}

.stat .sub {
  color: var(--haze);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .stat-strip {
    grid-template-columns: 1fr;
  }
  .stat + .stat {
    border-left: 0;
    border-top: 1px solid var(--rail-soft);
  }
}

.panel {
  padding: 1.3rem;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-lg);
  background: var(--deck);
}

.panel > p {
  margin-top: 0.4rem;
  color: var(--haze);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.stack {
  display: grid;
  gap: 1.2rem;
}

.detail-list {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.detail-list > div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 0.8rem;
}

.detail-list dt {
  color: var(--haze);
  font-size: 0.88rem;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.toolbar .search {
  flex: 1 1 240px;
}

.table-wrap {
  overflow-x: auto;
  margin-inline: -1.3rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.7rem 1.3rem;
  border-bottom: 1px solid var(--rail-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--haze);
  font-weight: 600;
  font-size: 0.82rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: rgba(35, 39, 74, 0.5);
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

td.actions .btn + .btn {
  margin-left: 0.4rem;
}

/* ==========================================================================
   Legal pages
   ========================================================================== */

.legal {
  width: 100%;
  max-width: calc(68ch + 32px);
  margin: 0 auto;
  padding: 3rem 16px 0;
  line-height: 1.7;
}

.legal h1 {
  margin-bottom: 0.4rem;
}

.legal h2 {
  margin: 2.2rem 0 0.7rem;
  font-size: 1.2rem;
}

.legal p,
.legal ul {
  margin: 0 0 1rem;
  color: #d3d5ec;
}

.legal ul {
  padding-left: 1.3rem;
}

.legal li + li {
  margin-top: 0.4rem;
}

.legal-footer {
  margin-top: 2.5rem;
  color: var(--haze);
}

[hidden] {
  display: none !important;
}

/* Dashboard top navigation */
.main-nav {
  display: flex;
  gap: 0.2rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--deck);
}

.main-nav button {
  padding: 0.4rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--haze);
  font: 600 0.86rem var(--body);
  white-space: nowrap;
  cursor: pointer;
}

.main-nav button:hover {
  color: var(--chalk);
}

.main-nav button[aria-current="page"] {
  background: var(--deck-2);
  color: var(--chalk);
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
  }
  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .main-nav {
    order: 3;
    width: 100%;
  }
  .main-nav button {
    flex: 1;
  }
}

/* ==========================================================================
   Server console (owner view): sidebar + content
   ========================================================================== */

.small-text {
  font-size: 0.82rem;
}

.initial img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.initial {
  overflow: hidden;
}

.initial.big {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 1.2rem;
}

.console {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  flex: 1 0 auto;
  width: 100%;
}

.console-side {
  position: sticky;
  top: 64px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  height: calc(100vh - 64px);
  padding: 1.4rem 1rem;
  border-right: 1px solid var(--rail-soft);
  background: #161830;
  overflow-y: auto;
}

.server-switch {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem;
  border-radius: var(--r-md);
  background: var(--deck);
}

.server-switch .grow {
  flex: 1;
  min-width: 0;
}

.server-switch strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 0.98rem;
}

.server-switch select {
  margin-top: 0.35rem;
  min-height: 30px;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
}

.console .side-nav {
  position: static;
  display: grid;
  gap: 0.15rem;
}

.nav-group {
  margin: 0.9rem 0 0.25rem 0.75rem;
  color: var(--dim);
  font-size: 0.78rem;
  font-weight: 600;
}

.nav-group:first-child {
  margin-top: 0;
}

.console .side-nav button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
}

.console .side-nav svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.console .side-nav button.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.side-invite {
  margin-top: auto;
  padding: 0.7rem 0.75rem;
  border: 1px dashed var(--rail);
  border-radius: var(--r-md);
  color: var(--haze);
  font-size: 0.85rem;
}

.side-invite:hover {
  color: var(--chalk);
  border-color: var(--haze);
  text-decoration: none;
}

.console-main {
  min-width: 0;
  padding: 2rem clamp(16px, 3vw, 2.6rem) 3rem;
}

.console-main > section {
  display: grid;
  gap: 1.2rem;
  max-width: 1080px;
}

.console-main > section.hidden {
  display: none !important;
}

.console-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.console-head h1 {
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem);
}

.console-head p {
  margin-top: 0.3rem;
}

.console-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.console .stat-strip {
  margin-bottom: 0;
}

.stat-strip.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.2rem;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.with-avatar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.mini-avatar {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--deck-2);
}

/* Setup checklist: a real sequence, so numbered; done steps get a check. */
.checklist ol {
  display: grid;
  gap: 0.55rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: check;
}

.checklist li {
  counter-increment: check;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.checklist li::before {
  content: counter(check);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--rail);
  color: var(--haze);
  font-size: 0.78rem;
  font-weight: 700;
}

.checklist li.done {
  color: var(--haze);
  text-decoration: line-through;
}

.checklist li.done::before {
  content: "\2713";
  border-color: var(--ok);
  background: var(--ok);
  color: var(--ink);
}

/* Activity feed */
.activity {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rail-soft);
  font-size: 0.9rem;
}

.activity li:last-child {
  border-bottom: 0;
}

.activity .grow {
  flex: 1;
  min-width: 0;
}

.activity time {
  font-size: 0.8rem;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--haze);
}

.dot.link {
  background: #55a83c;
}

.dot.grant {
  background: #7c86ff;
}

/* Charts */
.chart {
  position: relative;
  min-height: 150px;
}

.chart svg {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.chart .grid {
  stroke: var(--rail-soft);
  stroke-width: 1;
}

.chart .axis {
  fill: var(--dim);
  font: 11px var(--body);
}

.chart .hover-band {
  fill: rgba(124, 134, 255, 0.08);
  transition: opacity 0.1s;
}

.chart-tip {
  position: absolute;
  top: 0;
  z-index: 2;
  min-width: 130px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rail);
  border-radius: var(--r-sm);
  background: var(--ink);
  font-size: 0.8rem;
  pointer-events: none;
  transform: translateX(-50%);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.chart-tip strong {
  display: block;
  margin-bottom: 0.25rem;
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--haze);
}

.tip-row b {
  margin-left: auto;
  color: var(--chalk);
  font-variant-numeric: tabular-nums;
}

.tip-row i,
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend {
  display: flex;
  gap: 1rem;
  color: var(--haze);
  font-size: 0.82rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-table {
  margin-top: 0.8rem;
  font-size: 0.85rem;
}

.chart-table summary {
  color: var(--haze);
  cursor: pointer;
}

.chart-table table {
  margin-top: 0.6rem;
}

.chart-table td,
.chart-table th {
  padding: 0.4rem 0.6rem;
}

/* API key card */
.key-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.key-row .grow {
  flex: 1;
  min-width: 0;
}

.key-preview {
  margin-top: 0.3rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-sm);
  background: #0f1124;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.setup-steps {
  display: grid;
  gap: 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: setup;
}

.setup-steps > li {
  counter-increment: setup;
  position: relative;
  padding-left: 3.6rem;
}

.setup-steps > li::before {
  content: counter(setup);
  position: absolute;
  left: 1.2rem;
  top: 1.25rem;
  color: var(--accent);
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
}

.setup-steps p {
  margin-top: 0.4rem;
  color: var(--haze);
}

body.is-console .site-footer {
  display: none;
}

@media (max-width: 1100px) {
  .stat-strip.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-strip.four .stat:nth-child(3) {
    border-left: 0;
  }
  .stat-strip.four .stat:nth-child(n + 3) {
    border-top: 1px solid var(--rail-soft);
  }
  .console-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .console {
    grid-template-columns: 1fr;
  }
  .console-side {
    position: static;
    height: auto;
    gap: 0.8rem;
    padding: 0.9rem 16px 0;
    border-right: 0;
    border-bottom: 1px solid var(--rail-soft);
  }
  .console .side-nav {
    display: flex;
    overflow-x: auto;
    gap: 0.2rem;
    padding-bottom: 0.5rem;
  }
  .nav-group,
  .side-invite {
    display: none;
  }
  .console .side-nav button {
    flex: none;
  }
  .console .side-nav button.active {
    box-shadow: inset 0 -2px 0 var(--accent);
  }
  .console-main {
    padding-top: 1.4rem;
  }
}

@media (max-width: 520px) {
  .stat-strip.four {
    grid-template-columns: 1fr;
  }
  .stat-strip.four .stat + .stat {
    border-left: 0;
    border-top: 1px solid var(--rail-soft);
  }
}

/* The dashboard top bar is always full width, so switching between the
   server console and the other pages never moves the logo or navigation. */
body.dash .topbar {
  padding-inline: 1.2rem;
}

/* ==========================================================================
   View transitions, clickable rows, player drawer, phone layout
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  .view-enter {
    animation: view-in 0.18s ease-out;
  }
}

@keyframes view-in {
  from {
    opacity: 0;
  }
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Player drawer: slides in from the right; a bottom sheet on phones. */
.modal.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(460px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  border-right: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .modal.drawer[open] {
    animation: drawer-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@keyframes drawer-in {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
}

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100%;
  padding: 1.3rem;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.drawer-head .grow {
  flex: 1;
  min-width: 0;
}

.drawer-head h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-head .initial.big {
  width: 52px;
  height: 52px;
}

#player-sections {
  display: grid;
  gap: 0.8rem;
}

.dsection {
  padding: 1rem;
  border-radius: var(--r-md);
  background: var(--ink);
}

.dsection-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.dsection-head h3 {
  flex: 1;
}

.dsection-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--deck-2);
}

.dsection dl {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.drow {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 0.6rem;
  align-items: center;
  font-size: 0.9rem;
}

.drow dt {
  color: var(--haze);
}

.drow dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.copy-inline {
  min-height: 26px;
  padding: 0.1rem 0.5rem;
  font-size: 0.78rem;
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 0.6rem;
}

/* ------------------------------------------------------------------ phone */

@media (max-width: 640px) {
  body {
    font-size: 14.5px;
  }

  .topbar {
    min-height: 56px;
    gap: 0.6rem;
    padding-block: 0.5rem;
  }

  .brand-link {
    font-size: 1.05rem;
  }

  .topbar-actions {
    gap: 0.35rem;
  }

  .main-nav button {
    padding: 0.5rem 0.6rem;
  }

  .page {
    padding-top: 1.4rem;
  }

  .page-head,
  .account-head {
    margin-bottom: 1.4rem;
  }

  .account-head .avatar {
    width: 44px;
    height: 44px;
  }

  .panel,
  .identity-summary,
  .danger-zone {
    padding: 1rem;
  }

  .table-wrap {
    margin-inline: -1rem;
  }

  .console-side {
    top: auto;
  }

  .console-main {
    padding: 1.1rem 16px 2.5rem;
  }

  .console-main > section {
    gap: 1rem;
  }

  .console-head h1 {
    font-size: 1.5rem;
  }

  /* Two compact columns of numbers instead of one tall list. */
  .stat-strip,
  .stat-strip.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-strip .stat,
  .stat-strip.four .stat {
    padding: 0.85rem 0.9rem;
    border-left: 0;
    border-top: 0;
  }
  .stat-strip .stat:nth-child(even) {
    border-left: 1px solid var(--rail-soft);
  }
  .stat-strip .stat:nth-child(n + 3) {
    border-top: 1px solid var(--rail-soft);
  }
  .stat .value {
    font-size: 1.45rem;
  }
  .stat .sub {
    display: none;
  }

  .toolbar .search {
    flex-basis: 100%;
  }

  /* Tables become stacked cards: each cell shows its column name. */
  table.cards-sm thead {
    display: none;
  }
  table.cards-sm,
  table.cards-sm tbody {
    display: block;
  }
  table.cards-sm tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.8rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--rail-soft);
  }
  table.cards-sm tbody tr:last-child {
    border-bottom: 0;
  }
  table.cards-sm td {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    grid-column: 1 / -1;
    padding: 0;
    border: 0;
    text-align: right;
  }
  table.cards-sm td::before {
    content: attr(data-label);
    color: var(--haze);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
  }
  table.cards-sm td.actions {
    justify-content: flex-end;
    margin-top: 0.3rem;
  }
  table.cards-sm td.actions::before {
    content: none;
  }
  table.cards-sm tbody tr:hover td {
    background: transparent;
  }

  .modal.drawer {
    inset: auto 0 0 0;
    width: 100%;
    height: auto;
    max-height: 88dvh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-right: 1px solid var(--rail);
    border-bottom: 0;
  }
  .drawer-body {
    min-height: 0;
    padding: 1.1rem 16px 1.3rem;
  }
  @media (prefers-reduced-motion: no-preference) {
    .modal.drawer[open] {
      animation: sheet-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
  }
  .drow {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .modal {
    width: calc(100% - 24px);
  }

  .site-footer {
    margin-top: 2.5rem;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

/* Very small phones: hide the account chip to keep the top bar on one row. */
@media (max-width: 380px) {
  .user-chip {
    display: none !important;
  }
}

/* Keep every column shrinkable so wide content (tables, charts) never
   pushes the page wider than the screen. */
.console {
  grid-template-columns: 252px minmax(0, 1fr);
}

.console-main > section > *,
.console-grid > *,
.home-grid > * {
  min-width: 0;
}

@media (max-width: 860px) {
  .console {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  /* Top bar: logo + account on the first row, navigation full width below. */
  body.dash .topbar {
    flex-wrap: wrap;
  }
  body.dash .topbar-actions {
    display: contents;
  }
  body.dash .user-chip {
    margin-left: auto;
  }
  body.dash .main-nav {
    order: 3;
    width: 100%;
  }
  .console-side {
    overflow: hidden;
  }
}

/* Dialogs: the UA stylesheet caps max-width/height; the drawer manages its own. */
.modal.drawer {
  max-width: 100%;
}

.drow dd {
  flex-wrap: nowrap;
  align-items: flex-start;
}

.drow .dval {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.drow .copy-inline {
  flex: none;
  margin-top: -0.2rem;
}

/* Sharing switch polish: fixed-width label (no layout jump) and eased motion. */
.switch {
  transition: color 0.2s ease;
}

.switch .switch-label {
  min-width: 3.7em;
  text-align: left;
}

.switch .track,
.switch .track::after {
  transition-timing-function: cubic-bezier(0.3, 0.7, 0.2, 1);
  transition-duration: 0.22s;
}

.switch[aria-busy="true"] {
  cursor: progress;
}

@media (prefers-reduced-motion: reduce) {
  .switch,
  .switch .track,
  .switch .track::after {
    transition: none;
  }
}

/* Roles & logs page */
.role-rows {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.4rem;
  transition: opacity 0.2s;
}

.role-rows.is-off {
  opacity: 0.45;
  pointer-events: none;
}

.role-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--r-md);
  background: var(--ink);
}

.role-row .grow {
  flex: 1;
  min-width: 0;
}

.role-dot {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
}

.hint-text {
  color: var(--dim);
  font-size: 0.8rem;
  font-weight: 400;
}

.checks {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  border: 0;
  transition: opacity 0.2s;
}

.checks:disabled {
  opacity: 0.45;
}

.checks legend {
  margin-bottom: 0.4rem;
  padding: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--chalk);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
}

.check input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.save-bar {
  position: sticky;
  bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-md);
  background: rgba(27, 30, 54, 0.92);
  backdrop-filter: blur(8px);
}

#discord-error {
  margin: 0;
}

@media (max-width: 640px) {
  .role-row {
    flex-wrap: wrap;
  }
  .save-bar {
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  .role-row {
    position: relative;
    display: block;
  }
  .role-row .role-dot {
    display: none;
  }
  .role-row .switch {
    position: absolute;
    top: 0.55rem;
    right: 0.7rem;
  }
}

img.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

/* ==========================================================================
   Server console on phones/tablets: hamburger + off-canvas sidebar.
   Overrides the earlier horizontal-tab fallback.
   ========================================================================== */

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

.side-toggle,
.side-backdrop {
  display: none;
}

body.no-scroll {
  overflow: hidden;
}

@media (max-width: 860px) {
  .side-toggle {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.8rem 16px;
    border: 0;
    border-bottom: 1px solid var(--rail-soft);
    background: #161830;
    color: var(--chalk);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  .side-toggle svg {
    width: 22px;
    height: 22px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  .side-toggle .grow {
    flex: 1;
    min-width: 0;
  }

  .side-toggle strong {
    display: block;
    font-family: var(--display);
    font-size: 1rem;
  }

  .side-toggle .muted {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
  }

  .side-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(8, 9, 20, 0.6);
  }

  /* The sidebar slides in from the left. */
  .console .console-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 41;
    display: flex;
    width: min(300px, 86vw);
    height: 100dvh;
    padding: 1.2rem 1rem;
    border-right: 1px solid var(--rail);
    border-bottom: 0;
    overflow-y: auto;
    transform: translateX(-102%);
    visibility: hidden;
    transition:
      transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1),
      visibility 0s linear 0.24s;
  }

  .console.side-open .console-side {
    transform: none;
    visibility: visible;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
  }

  .console .side-nav {
    display: grid;
    overflow: visible;
    padding-bottom: 0;
  }

  .console .nav-group {
    display: block;
  }

  .console .side-invite {
    display: block;
  }

  .console .side-nav button {
    padding: 0.7rem 0.75rem;
  }

  .console .side-nav button.active {
    box-shadow: inset 3px 0 0 var(--accent);
  }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .console .console-side,
  .console.side-open .console-side {
    transition: none;
  }
}

@media (max-width: 860px) {
  .console .side-nav {
    border-bottom: 0;
  }
}

.tips {
  display: grid;
  gap: 0.55rem;
  margin: 0.7rem 0 0;
  padding-left: 1.1rem;
  color: var(--haze);
}

.tips strong {
  color: var(--chalk);
}

/* Discord tile uses Discord's own look: white mark on blurple. */
.node.dc .tile {
  border-color: #5865f2;
  background: #5865f2;
  color: #fff;
}

.node.dc .tile svg {
  width: 54%;
  height: 54%;
}

/* ---------------------------------------------------------------- landing v2 */

.section {
  padding-block: clamp(2.6rem, 6vw, 4.6rem);
}

.section-title-lg {
  margin-bottom: 1.6rem;
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem);
  font-weight: 750;
}

.steps p {
  font-size: 0.95rem;
}

.split {
  align-items: center;
}

.ticks {
  display: grid;
  gap: 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ticks li {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 1.08rem;
}

.ticks li::before {
  content: "";
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-0.1rem);
}

.split .cta-row {
  margin-top: 1.8rem;
}

.code-card {
  margin: 0;
  padding: 1.2rem;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-lg);
  background: var(--deck);
}

.code-card figcaption {
  color: var(--dim);
  font: 0.8rem var(--mono);
}

.code-card pre {
  margin: 0.7rem 0 0.9rem;
  font-size: 1.05rem;
}

.code-card .k {
  color: #9aa3ff;
}

.code-card .v {
  color: var(--ok);
}

.code-card p {
  color: var(--haze);
  font-size: 0.92rem;
}

.cmd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.cmd-chips code {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--rail-soft);
  border-radius: var(--r-sm);
  background: var(--deck);
  font-size: 0.95rem;
}

.closing h2 {
  margin: 0;
}

@media (max-width: 880px) {
  #players .share-demo {
    order: 2;
  }
}

.hero-graph {
  width: 100%;
}

/* Names in the diagram truncate instead of breaking mid-word. */
.graph .node-meta {
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: normal;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.activity strong {
  color: var(--chalk);
  font-weight: 650;
}

.activity .grow {
  color: var(--haze);
}

.activity .badge {
  padding: 0.05rem 0.4rem;
  font-size: 0.68rem;
  vertical-align: 1px;
}

.dot.admin {
  background: var(--warn);
}

/* ==========================================================================
   Phone fixes
   ========================================================================== */

/* <figure> has a 40px side margin by default, which pushed the hero diagram
   off the right edge on phones. */
.hero-graph {
  margin: 0;
}

@media (max-width: 880px) {
  .hero,
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .hero {
    gap: 2rem;
  }
  .cta-row .btn {
    flex: 1 1 auto;
  }

  /* Dashboard top bar: logo left, account + log out right, tabs below. */
  body.dash .brand-link {
    margin-right: auto;
  }
  body.dash .user-chip {
    margin-left: 0;
  }

  /* Stacked player cards: labels in the body font, actions full width. */
  table.cards-sm td::before {
    font-family: var(--body);
  }
  table.cards-sm td.actions {
    justify-content: stretch;
    margin-top: 0.5rem;
  }
  table.cards-sm td.actions .btn {
    flex: 1;
    border: 1px solid var(--rail);
  }

  /* My accounts: server details wrap instead of being cut off. */
  .list-row.community .sub {
    white-space: normal;
  }
  .community .actions {
    padding-left: 0;
  }
}

@media (max-width: 380px) {
  .hero-graph .graph,
  .account-graph .graph {
    --tile: 52px;
  }
  .node-label {
    font-size: 0.85rem;
  }
  .node-meta {
    font-size: 0.78rem;
  }
}
