/* Reset, раскладка (топбар + сайдбар + контент) и типографика. Подключается ПОСЛЕ tokens.css. */

*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body) / 1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
svg { display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-ctl);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 52px;
  padding: 0 var(--sp-4);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 650;
  letter-spacing: .01em;
  color: var(--text);
}
.brand .mark {
  width: 8px;
  height: 18px;
  border-radius: 2px;
  background: var(--accent);
}

.topbar .spacer { margin-left: auto; }

/* Полоса не имеет права растягивать страницу.
   Содержимое топбара (бренд, выбор сервера, период, тема, выход) занимает около
   540 пикселей и во флексе без переноса просто выпирало наружу: при вьюпорте 375
   documentElement.scrollWidth равнялся 540, и вбок ехала ВСЯ страница — на всех
   разделах сразу, потому что полоса общая.
   Прокручиваем саму полосу, а не страницу: ни один элемент управления не
   прячется, высота (от неё считаются `top` сайдбара и `min-height` сетки)
   остаётся прежней. */
.topbar { min-width: 0; }
.topbar > * { flex: 0 0 auto; }
#guildSel { min-width: 0; max-width: 42vw; }

@media (max-width: 760px) {
  .topbar {
    gap: var(--sp-2);
    padding: 0 var(--sp-2);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { height: 0; }
}

.app {
  display: grid;
  grid-template-columns: var(--w-sidebar) minmax(0, 1fr);
  min-height: calc(100vh - 53px);
}

.sidebar {
  position: sticky;
  top: 53px;
  height: calc(100vh - 53px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.nav-sec { margin-bottom: var(--sp-2); }
.nav-sec > .nav-cap {
  display: block;
  padding: 0 var(--sp-2) var(--sp-1);
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--text-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px var(--sp-2);
  border-radius: var(--r-ctl);
  color: var(--text-2);
  font-size: var(--fs-body);
  transition: background var(--t-hover), color var(--t-hover);
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--text);
  font-weight: 600;
}
.nav-item .ico { flex: none; width: 16px; height: 16px; color: var(--text-3); }
.nav-item.active .ico { color: var(--accent); }
.nav-item .hint {
  margin-left: auto;
  font-size: var(--fs-micro);
  color: var(--text-3);
}

.sidebar .side-foot {
  margin-top: auto;
  padding: var(--sp-2);
  font-size: var(--fs-micro);
  color: var(--text-3);
  line-height: 1.5;
}

.content { min-width: 0; }

.page {
  max-width: var(--w-content-max);
  margin: 0 auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.page-title { font-size: var(--fs-page-title); font-weight: 650; }

.sec-title {
  font-size: var(--fs-sec-title);
  font-weight: 600;
  color: var(--text-2);
}

.meta { font-size: var(--fs-meta); color: var(--text-3); }
.micro { font-size: var(--fs-micro); color: var(--text-3); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }

.term {
  border-bottom: 1px dashed var(--line-strong);
  cursor: help;
}
/* Подсказка доступна и с клавиатуры, поэтому фокус обязан быть виден. */
.term:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 3px; }

@media (max-width: 1100px) {
  .app { grid-template-columns: var(--w-sidebar-narrow) minmax(0, 1fr); }
  .sidebar { padding: var(--sp-4) var(--sp-2); }
  .nav-sec > .nav-cap { visibility: hidden; height: 8px; padding: 0; }
  .nav-item { justify-content: center; padding: 8px 0; }
  .nav-item .txt, .nav-item .hint { display: none; }
  .side-foot { display: none; }
}

/* Гасим движение и бесконечные циклы, цветовые переходы оставляем. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-iteration-count: 1 !important;
    transition-property: opacity, color, background-color, border-color, box-shadow !important;
  }
  .skel::after { animation: none !important; }
  .toast { animation-duration: .01ms !important; }
  .drawer, .tgl::after, .prog > i { transition: none !important; }
}
