:root{
  --gutter: 16px;
  --z-header: 50;
  --border: rgba(255,255,255,.08);

  /* Desktop control height */
  --desktop-btn-h: 53px;

  --text: rgba(255,255,255,.90);
  --muted: rgba(255,255,255,.66);

  --violet: 160 120 255;
  --green: 88 242 140;
  --blue: 90 170 255;

  --card: rgba(255,255,255,.045);
  --card2: rgba(255,255,255,.07);

  --ring: rgba(160,120,255,.55);
  --shadow: 0 16px 44px rgba(0,0,0,.45);

  --toast-bg: rgba(12,14,20,.78);
  --toast-border: rgba(255,255,255,.14);
  --toast-shadow: 0 22px 60px rgba(0,0,0,.55);

  --font-ui: "Manrope", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-display: "Unbounded", var(--font-ui);

  --header-h: 0px;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  padding-top: var(--header-h);

  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(160,120,255,.14), transparent 60%),
    radial-gradient(900px 520px at 95% 0%, rgba(88,242,140,.08), transparent 55%),
    #0b0d12;
  font-family: var(--font-ui);
  color: var(--text);
}

.container{
  width: min(1120px, calc(100% - (var(--gutter) * 2)));
  margin-inline: auto;
}

/* ================= Header ================= */
.header{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);

  backdrop-filter: blur(14px);
  background:
    linear-gradient(180deg, rgba(11, 13, 18, 0.78), rgba(11, 13, 18, 0.60));
  border-bottom: 1px solid rgba(255,255,255,.08);

  transform: translateY(0);
  will-change: transform;
}

.header::before{
  content:"";
  position:absolute;
  inset: 0;
  pointer-events:none;
  background:
    radial-gradient(900px 120px at 30% 0%, rgba(160,120,255,.16), transparent 60%),
    radial-gradient(700px 120px at 80% 0%, rgba(88,242,140,.10), transparent 60%);
  opacity: .9;
}

.header__row{
  position: relative;
  display:grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items:center;
  gap: 14px;
  padding: 10px 0;
}

.header__left{
  display:flex;
  align-items:center;
  gap: 18px;
  min-width: 0;
}

.header__center{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width: 0;
}

.header__right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;

  /* ✅ важно: для grid — прижимаем элемент к правому краю его области */
  justify-self: end;
}

.brand{ display:inline-flex; align-items:center; min-width:0; text-decoration:none; }
.brand__logo{
  display:block;
  height: 58px;
  width:auto;
  object-fit:contain;
  filter: drop-shadow(0 10px 22px rgba(160, 120, 255, 0.22));
}

/* Desktop text links near logo */
.header-nav{
  display:flex;
  align-items:center;
  gap: 16px;
}
.header-nav__link{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;

  color: rgba(255,255,255,.76);
  text-decoration: none;
  padding: 10px 10px;
  border-radius: 999px;
  position: relative;
  transition: color .18s ease, transform .14s ease, background .18s ease;
}
.header-nav__link:hover{
  color: #fff;
  transform: translateY(-1px);
  background: rgba(255,255,255,.06);
}

/* Actions */
.actions{ display:flex; align-items:center; gap: 10px; }

/* icons */
.icon{ width: 20px; height: 20px; }
.icon--social{ width: 24px; height: 24px; }
.icon--account{ width: 24px; height: 24px; }
.icon--copy{ width: 18px; height: 18px; }

.icon-btn, .account, .burger, .menu__item, .server, .server-mini{
  -webkit-tap-highlight-color: transparent;
}

/* ================= Social icon buttons ================= */
.icon-btn{
  width: var(--desktop-btn-h);
  height: var(--desktop-btn-h);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.10);

  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,.12), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  color: #fff;
  cursor:pointer;

  box-shadow:
    0 12px 28px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.10);

  position: relative;
  overflow: hidden;
  transition: transform .14s ease, border-color .18s ease, box-shadow .18s ease, filter .18s ease;
}
.icon-btn::after{
  content:"";
  position:absolute;
  inset: -40% -60%;
  background: linear-gradient(120deg, transparent 45%, rgba(255,255,255,.22) 50%, transparent 55%);
  transform: translateX(-40%) rotate(8deg);
  opacity: 0;
  transition: opacity .2s ease, transform .6s ease;
}
.icon-btn:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.18);
  box-shadow:
    0 18px 44px rgba(0,0,0,.40),
    inset 0 1px 0 rgba(255,255,255,.12);
}
.icon-btn:hover::after{
  opacity: 1;
  transform: translateX(40%) rotate(8deg);
}
.icon-btn--vk:hover{
  box-shadow:
    0 18px 44px rgba(0,0,0,.40),
    0 0 0 1px rgba(90,170,255,.18),
    0 0 28px rgba(90,170,255,.16),
    inset 0 1px 0 rgba(255,255,255,.12);
}
.icon-btn--tg:hover{
  box-shadow:
    0 18px 44px rgba(0,0,0,.40),
    0 0 0 1px rgba(88,242,140,.16),
    0 0 30px rgba(88,242,140,.14),
    inset 0 1px 0 rgba(255,255,255,.12);
}
.icon-btn--ds:hover{
  box-shadow:
    0 18px 44px rgba(0,0,0,.40),
    0 0 0 1px rgba(160,120,255,.20),
    0 0 34px rgba(160,120,255,.18),
    inset 0 1px 0 rgba(255,255,255,.12);
}

/* ================= Account ================= */
.account{
  display:inline-flex;
  align-items:center;
  gap: 10px;
  height: var(--desktop-btn-h);
  padding: 0 16px 0 12px;
  border-radius: 16px;

  border: 1px solid rgba(255,255,255,.10);
  background:
    radial-gradient(140% 120% at 30% 20%, rgba(255,255,255,.12), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.03));
  color: #fff;
  cursor:pointer;

  box-shadow:
    0 14px 34px rgba(0,0,0,.30),
    inset 0 1px 0 rgba(255,255,255,.10);

  transition: transform .14s ease, border-color .18s ease, box-shadow .18s ease, filter .18s ease;
  position: relative;
  overflow:hidden;
  min-width: 0;
}

/* ✅ Контент выше псевдо-слоёв */
.account > *{
  position: relative;
  z-index: 2;
}

/* ✅ Мягкое фиолетовое свечение (бывший ::after) */
.account::before{
  content:"";
  position:absolute;
  inset: -60% -60%;
  background: radial-gradient(closest-side, rgba(160,120,255,.26), transparent 60%);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events:none;
  z-index: 0;
}

/* ✅ Блик-пробег, как у соцсетей (аналог icon-btn::after) */
.account::after{
  content:"";
  position:absolute;
  inset: -40% -60%;
  background: linear-gradient(120deg, transparent 45%, rgba(255,255,255,.22) 50%, transparent 55%);
  transform: translateX(-40%) rotate(8deg);
  opacity: 0;
  transition: opacity .2s ease, transform .6s ease;
  pointer-events:none;
  z-index: 1;
}

.account:hover{
  transform: translateY(-1px);
  border-color: rgba(160,120,255,.22);
  box-shadow:
    0 20px 54px rgba(0,0,0,.42),
    0 0 34px rgba(160,120,255,.14),
    inset 0 1px 0 rgba(255,255,255,.12);
  filter: brightness(1.01);
}

/* ✅ запускаем тот же sweep */
.account:hover::after{
  opacity: 1;
  transform: translateX(40%) rotate(8deg);
}

/* ✅ оставляем фирменное свечение */
.account:hover::before{ opacity: 1; }

.account__avatar{
  width: 34px;
  height: 34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(160,120,255,.22), rgba(160,120,255,.08));
  border: 1px solid rgba(160,120,255,.28);
}
.account__label{
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 7ch;
  min-width: 0;
}

/* ================= Server mini ================= */
.server-mini{
  position: relative;
  display: grid;

  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto 6px;
  grid-template-areas:
    "ipline dot count"
    "bar   bar bar";

  align-items: center;
  column-gap: 10px;
  row-gap: 8px;

  height: var(--desktop-btn-h);
  padding: 10px 14px;
  border-radius: 16px;

  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);

  color: #fff;
  cursor: pointer;
  min-width: 0;
  width: 100%;
  max-width: 720px;

  box-shadow: 0 10px 26px rgba(0,0,0,.28);
  transition: transform .14s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
  overflow: visible;
}
.server-mini:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.055);
  border-color: rgba(255,255,255,.16);
  box-shadow: 0 16px 38px rgba(0,0,0,.40);
}

.server-mini__ipline{
  grid-area: ipline;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.server-mini__hint{
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255,255,255,.60);
  white-space: nowrap;
}
.server-mini__ip{
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.server-mini__dot{
  grid-area: dot;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgb(var(--green) / .95);
  box-shadow: 0 0 0 3px rgb(var(--green) / .16);
  align-self: center;
  justify-self: end;
  margin-right: 2px;
}

.server-mini__count{
  grid-area: count;
  justify-self: end;
  font-size: 12px;
  color: rgba(255,255,255,.78);
  white-space: nowrap;
  font-weight: 800;
}

.server-mini__bar{
  grid-area: bar;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.10);
  overflow: hidden;
  pointer-events: none;
}
.server-mini__fill{
  display:block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(var(--violet) / .9), rgb(var(--green) / .75));
  transition: width .35s ease;
}

/* ================= Burger server ================= */
.server{
  width: 100%;
  margin: 0;
  display:flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px;
  border-radius: 16px;

  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);

  cursor: pointer;
  position: relative;

  box-shadow: 0 10px 26px rgba(0,0,0,.28);
  transition: transform .14s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
  overflow: visible;
}
.server:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.055);
  border-color: rgba(255,255,255,.16);
  box-shadow: 0 16px 38px rgba(0,0,0,.40);
}

.server__top{ display:flex; align-items:center; justify-content: space-between; gap: 10px; min-width: 0; }
.server__ip{ display:flex; align-items: center; gap: 10px; min-width: 0; }
.server__hint{
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255,255,255,.60);
}
.server__value{
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server__copy{ opacity: .8; display:inline-flex; transform: translateY(1px); }

.server__online{
  display:flex;
  align-items:center;
  gap: 8px;
  color: rgba(255,255,255,.78);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
.server__dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgb(var(--green) / .95);
  box-shadow: 0 0 0 3px rgb(var(--green) / .16);
}

.server__bar{
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.10);
  overflow:hidden;
}
.server__fill{
  display:block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(var(--violet) / .9), rgb(var(--green) / .75));
  transition: width .35s ease;
}
.server__meta{ font-size: 12px; color: rgba(255,255,255,.64); font-weight: 700; }

/* ================= Toast ================= */
.server-mini__toast,
.server__toast{
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  transform: translateX(-50%) translateY(12px) scale(.98);
  transform-origin: top center;
  z-index: 60;

  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 10px 14px 10px 12px;
  border-radius: 999px;

  background:
    radial-gradient(120% 220% at 20% 0%, rgba(255,255,255,.10), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)),
    var(--toast-bg);

  border: 1px solid var(--toast-border);
  box-shadow:
    var(--toast-shadow),
    inset 0 1px 0 rgba(255,255,255,.08);

  backdrop-filter: blur(16px) saturate(170%);
  -webkit-backdrop-filter: blur(16px) saturate(170%);

  color: rgba(255,255,255,.92);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  white-space: nowrap;

  opacity: 0;
  pointer-events: none;

  transition: opacity .18s ease, transform .18s ease, filter .18s ease;
  isolation: isolate;
}

.server-mini__toast::before,
.server__toast::before{
  content: "✓";
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: linear-gradient(135deg,
    rgb(var(--green) / .95),
    rgb(var(--violet) / .85)
  );
  color: #0b0d12;
  font-size: 13px;
  font-weight: 1000;

  box-shadow:
    0 10px 22px rgba(0,0,0,.35),
    0 0 0 1px rgba(255,255,255,.18);

  flex: 0 0 auto;
}

.server-mini__toast::after,
.server__toast::after{
  content:"";
  position:absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(90deg,
    rgb(var(--violet) / .42),
    rgb(var(--green) / .34)
  );
  filter: blur(16px);
  opacity: 0;
  z-index: -1;
  transition: opacity .18s ease;
}

.server-mini__toast.is-show,
.server__toast.is-show{
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  filter: brightness(1.03);
}
.server-mini__toast.is-show::after,
.server__toast.is-show::after{ opacity: .65; }

/* ================= Burger ================= */
.burger{
  display:none;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 16px;
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,.12), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  cursor:pointer;
  padding: 0;
  position: relative;
  box-shadow: 0 14px 34px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.10);
  transition: transform .14s ease, border-color .18s ease, box-shadow .18s ease;
}
.burger:hover{
  transform: translateY(-1px);
  border-color: rgba(160,120,255,.22);
  box-shadow: 0 20px 54px rgba(0,0,0,.40), 0 0 32px rgba(160,120,255,.12), inset 0 1px 0 rgba(255,255,255,.12);
}
.burger__line{
  position:absolute;
  left: 15px;
  height: 2px;
  background: rgba(255,255,255,.92);
  border-radius: 2px;
  transition: transform .18s ease, top .18s ease, width .18s ease, opacity .18s ease;
}
.burger__line--top{ top: 18px; width: 18px; }
.burger__line--bot{ top: 28px; width: 14px; }
.burger.is-open .burger__line--top{ top: 23px; width: 18px; transform: rotate(45deg); }
.burger.is-open .burger__line--bot{ top: 23px; width: 18px; transform: rotate(-45deg); }

/* ================= Menu overlay ================= */
.menu{
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) - 1);
  display: none;
}
.menu.is-open{ display:block; }

.menu__backdrop{
  position:absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  border: 0;
  padding: 0;
  cursor: pointer;
}
.menu__panel{
  position: absolute;
  right: max(var(--gutter), 16px);
  top: calc(var(--header-h) + 12px);

  width: min(380px, calc(100% - 32px));
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.10);

  background:
    radial-gradient(110% 70% at 20% 0%, rgba(160,120,255,.14), transparent 60%),
    radial-gradient(110% 70% at 95% 0%, rgba(88,242,140,.10), transparent 60%),
    rgba(11, 13, 18, 0.96);

  box-shadow: var(--shadow);
  padding: 10px;
  transform: translateY(-6px);
  opacity: 0;
  transition: transform .16s ease, opacity .16s ease;
  display: grid;
  gap: 10px;
}
.menu.is-open .menu__panel{ transform: translateY(0); opacity: 1; }

.menu__item{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.10);
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,.10), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  color: rgba(255,255,255,.92);
  text-decoration:none;
  font-weight: 800;
  letter-spacing: .01em;
  transition: transform .14s ease, border-color .18s ease, box-shadow .18s ease;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.10);
}
.menu__item:hover{
  transform: translateY(-1px);
  border-color: rgba(160,120,255,.18);
  box-shadow: 0 18px 44px rgba(0,0,0,.32), 0 0 26px rgba(160,120,255,.08), inset 0 1px 0 rgba(255,255,255,.12);
}
.menu__item-icon{ opacity: .9; display:inline-flex; align-items:center; }

/* Focus */
.icon-btn:focus-visible,
.account:focus-visible,
.burger:focus-visible,
.menu__item:focus-visible,
.server:focus-visible,
.server-mini:focus-visible,
.header-nav__link:focus-visible{
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ================= Breakpoints ================= */
@media (max-width: 980px){
  /* ✅ Мобильная “компактная шапка” */
  :root{
    --desktop-btn-h: 44px; /* было 53px */
  }

  .header{ backdrop-filter: blur(12px); }

  .burger{ display:inline-flex; }
  .header__center{ display:none; }
  .header-nav--desktop{ display:none; }
  .icon-btn{ display:none; }

  /* ✅ FIX: на мобилке делаем flex вместо grid,
     чтобы .actions точно прижимались вправо без “лишней колонки” и загадочного зазора */
  .header__row{
    display:flex;
    align-items:center;
    gap: 10px;          /* было 12px */
    padding: 6px 0;     /* было 10px 0 */
  }

  .header__left{
    flex: 1 1 auto;
    min-width: 0;
    gap: 12px;          /* было 18px */
  }

  .header__right{
    flex: 0 0 auto;
    margin-left: auto;      /* ✅ ключевое */
    justify-self: auto;
    gap: 8px;               /* было 10px */
  }

  /* чуть компактнее расстояние между burger и account на мобилке */
  .actions{ gap: 8px; }

  /* Лого меньше на мобилке */
  .brand__logo{ height: 44px; } /* было 58px */

  /* Account компактнее */
  .account{
    border-radius: 14px;
    padding: 0 12px 0 10px;  /* было 0 16px 0 12px */
  }
  .account__avatar{
    width: 30px; height: 30px;
    border-radius: 12px;
  }
  .account__label{
    font-size: 11px;
    letter-spacing: .06em;
    max-width: 6ch;
  }

  /* Burger компактнее */
  .burger{
    width: 44px; height: 44px;     /* было 48 */
    border-radius: 14px;           /* было 16 */
  }
  .burger__line{ left: 14px; }
  .burger__line--top{ top: 16px; width: 18px; } /* было 18px */
  .burger__line--bot{ top: 26px; width: 14px; } /* было 28px */
  .burger.is-open .burger__line--top{ top: 21px; }
  .burger.is-open .burger__line--bot{ top: 21px; }

  /* Панель меню ближе к шапке */
  .menu__panel{
    top: calc(var(--header-h) + 8px); /* было +12px */
    border-radius: 18px;
  }
}

@media (max-width: 720px){
  .server__meta{ display:none; }
  .account__label{ font-size: 10.5px; letter-spacing: .055em; }
  .account{ padding: 0 12px 0 10px; }
  .brand__logo{ height: 42px; }
}

@media (max-width: 420px){
  /* ещё чуть компактнее */
  :root{ --desktop-btn-h: 42px; }

  .header__row{ padding: 5px 0; gap: 8px; }

  .brand__logo{ height: 40px; }
  .account{
    padding: 0 10px 0 9px;
    border-radius: 13px;
  }
  .account__avatar{ width: 28px; height: 28px; border-radius: 11px; }
  .account__label{ font-size: 10px; letter-spacing: .05em; max-width: 6ch; }

  .burger{
    width: 42px; height: 42px;
    border-radius: 13px;
  }
  .burger__line{ left: 13px; }
  .burger__line--top{ top: 15px; }
  .burger__line--bot{ top: 25px; }
  .burger.is-open .burger__line--top{ top: 20px; }
  .burger.is-open .burger__line--bot{ top: 20px; }
}

@media (prefers-reduced-motion: reduce){
  .icon-btn,
  .account,
  .burger,
  .menu__item,
  .server,
  .server-mini,
  .server-mini__toast,
  .server__toast,
  .server-mini__toast::after,
  .server__toast::after{
    transition: none !important;
  }
}
