@font-face {
  font-family: Lora;
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("./fonts/lora-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Lora;
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("./fonts/lora-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --display: Lora, Georgia, "Times New Roman", serif;
  --bg: #11152d;
  --surface: #191f3b;
  --surface-raised: #222a4b;
  --surface-active: #2c365e;
  --surface-sunken: #131831;
  --ink: #f3f0ff;
  --muted: #b9c1e8;
  --muted-strong: #dbdff8;
  --border: #6273a0;
  --border-strong: #8090c2;
  --line: #364266;
  --dark: #0b0e20;
  --focus: #b5a8ff;
  --highlight: #c7baff;
  --accent: #ffc77e;
  --accent-hover: #ffdbab;
  --accent-ink: #271934;
  --danger: #ffacbe;
  --green: var(--highlight);
  --green-dark: #eee7ff;
  --green-wash: var(--surface-active);
  --lime: var(--accent);
  --lime-hover: var(--accent-hover);
  --content: 75rem;
  --sides: clamp(1rem, 4.25vw, 3rem);
  --small-radius: .43rem;
  --card-radius: .65rem;
  --shadow: none;
}

:focus-visible {
  outline-color: var(--focus);
  outline-width: 2px;
}

::selection { background: var(--accent); color: var(--accent-ink); }
.skip-link { color: var(--accent-ink); }

.site-header {
  border-bottom-color: var(--border);
  background: var(--surface-sunken);
  backdrop-filter: none;
}

.header-inner { min-height: 4.55rem; }

.brand { gap: .6rem; }
.brand-mark { width: 2.29rem; height: 2.29rem; }
.brand-name { color: var(--ink); font-size: 1.32rem; letter-spacing: -.05em; }
.brand-name span { color: var(--highlight); }

.main-nav { gap: .28rem; }

.nav-link {
  position: relative;
  min-height: 2.72rem;
  padding-inline: .85rem;
  font-size: .88rem;
}

.nav-link:hover { background: var(--surface-raised); color: var(--ink); }
.nav-link:is([aria-current="page"], [aria-selected="true"], .active, .is-active) {
  background: var(--surface-active);
  color: var(--ink);
}

.nav-link:is([aria-current="page"], [aria-selected="true"], .active, .is-active)::after {
  position: absolute;
  inset: auto .85rem .19rem;
  border-top: 1px solid var(--highlight);
  content: "";
}

.nav-link :is(.nav-unread, [data-chat-unread]) {
  min-width: 1.22rem;
  border-radius: 1rem;
  background: var(--highlight);
  color: var(--accent-ink);
  padding: .14rem .25rem;
  font-size: .68rem;
  line-height: 1.15;
  text-align: center;
}

.header-actions { gap: .45rem; }
.header-actions .icon-button, .header-actions .profile-button {
  min-height: 2.62rem;
  border-color: var(--border);
  background: transparent;
}
.icon-button:hover, .profile-button:hover, .profile-button[aria-current="page"] {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.button.primary, .button.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover, .button.button-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button.secondary, .button.button-secondary {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--ink);
}

.button.secondary:hover, .button.button-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-active);
}

.button.danger, .button.button-danger {
  border-color: #8c5475;
  background: #442942;
  color: var(--danger);
}

.button.danger:hover, .button.button-danger:hover {
  border-color: var(--danger);
  background: #56344b;
}

.site-main { padding: clamp(1.15rem, 2.6vw, 2.3rem) 0 4rem; }

.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) minmax(17.25rem, 20.25rem);
  gap: clamp(1.45rem, 3.15vw, 2.7rem);
  margin-top: clamp(2rem, 4.25vw, 3.4rem);
}

.section-heading { align-items: center; }
.section-heading h2 {
  font: 600 clamp(1.56rem, 3.1vw, 2.27rem) / 1.13 var(--display);
  letter-spacing: -.044em;
}

.section-heading p { margin-top: .43rem; }

.filter-bar { gap: .44rem; }
.filter-chip {
  min-height: 2.18rem;
  border-color: var(--border);
  background: transparent;
  padding-inline: .77rem;
}

.filter-chip:hover, .choice-chip:hover { border-color: var(--border-strong); }

.filter-chip:is(.active, .is-active, [aria-pressed="true"], [aria-selected="true"], [aria-current="true"]) {
  border-color: var(--highlight);
  background: var(--surface-active);
  color: var(--ink);
}

.news-grid { gap: 1.05rem; }

.news-card {
  min-width: 0;
  overflow: clip;
  border-color: var(--border);
  background: var(--surface);
}

.news-card:hover {
  transform: none;
  border-color: var(--border-strong);
  box-shadow: none;
}

.news-link:focus-visible { outline-offset: -3px; }

.news-cover {
  min-height: clamp(8.7rem, 12.25vw, 10.6rem);
  overflow: hidden;
  border-radius: 0;
  background-color: var(--surface-raised);
  padding: 0;
}

.news-cover > img { object-position: center; }

.news-kind {
  border: 0;
  border-radius: .23rem;
  background: var(--surface-raised);
  color: var(--highlight);
  padding: .19rem .35rem;
  font-size: .77rem;
  font-weight: 750;
}

.news-meta { color: var(--muted); margin-bottom: .42rem; }
.news-context { font-size: .77rem; font-weight: 650; }

.news-body { padding: .88rem .94rem .8rem; }
.news-body h3 { font-size: clamp(1.1rem, 1.65vw, 1.28rem); letter-spacing: -.032em; }
.news-body p { font-size: .95rem; line-height: 1.53; }
.news-footer { min-height: 1.85rem; margin-top: .78rem; font-size: .81rem; }
.news-details { text-decoration-thickness: 1px; text-underline-offset: .18em; }
.news-link:hover .news-details { text-decoration-line: underline; }

.team-sidebar {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface-raised);
}

.team-sidebar .section-heading {
  margin: 0;
  padding: .93rem 1rem .64rem;
}

.team-sidebar .section-heading h2 { font-size: clamp(1.42rem, 2.25vw, 1.69rem); }
.team-sidebar .section-heading p { margin-top: .34rem; font-size: .88rem; }

.sidebar-controls { margin: 0 1rem .8rem; }

.sidebar-controls .button {
  min-height: 2.43rem;
  border-color: var(--border-strong);
  background: var(--surface-sunken);
  color: var(--ink);
}

.sidebar-controls .button:hover {
  border-color: var(--highlight);
  background: var(--surface-active);
}

.sidebar-card {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
}

:is(.sidebar-item, .sidebar-team) {
  min-height: 5rem;
  align-items: center;
  color: var(--ink);
  padding: .71rem .84rem;
}

:is(.sidebar-item, .sidebar-team):hover { background: var(--surface-raised); }

.sidebar-item-content strong, .sidebar-team-copy strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  overflow: hidden;
  line-height: 1.32;
}

.sidebar-meta { column-gap: .23rem; font-size: .76rem; }
.sidebar-role { font-size: .79rem; }

.sidebar-all {
  min-height: 2.86rem;
  background: var(--surface-raised);
  color: var(--green-dark);
}

.sidebar-all:hover { background: var(--surface-active); }

.inner-page { padding-top: .45rem; }
.page-heading { margin-bottom: 1.35rem; }
.page-heading h1 {
  font: 500 clamp(2.35rem, 4.5vw, 3.68rem) / 1.05 var(--display);
  letter-spacing: -.042em;
}

.page-heading p { margin-top: .52rem; }

.team-card { padding: 1.15rem; }
.team-card h3 { font-size: 1.23rem; letter-spacing: -.032em; }
.team-card-goal { line-height: 1.58; }
.team-card-footer { padding-top: .52rem; }

.tag {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--muted-strong);
}

.type-badge {
  border-color: #665a92;
  background: #30294f;
  color: var(--highlight);
}
.type-badge.type-members { border-color: #655577; background: #342a4e; color: #f0caab; }

.site-dialog {
  border-color: var(--border-strong);
  border-radius: .75rem;
  box-shadow: 0 24px 70px #080b1b99;
}
.site-dialog::backdrop { background: #080b1bd1; backdrop-filter: none; }

.dialog-header h2, .profile-card-head h2 {
  font-size: clamp(1.5rem, 4vw, 1.98rem);
  letter-spacing: -.043em;
}

.dialog-body p > a { color: var(--highlight); }

.avatar, .sidebar-avatar {
  background: #303b68;
  color: var(--ink);
}

.sidebar-item:nth-child(3n + 2) .sidebar-avatar, .sidebar-team:nth-child(3n + 2) .sidebar-team-avatar {
  background: #3d3363;
  color: var(--highlight);
}

.sidebar-item:nth-child(3n + 3) .sidebar-avatar, .sidebar-team:nth-child(3n + 3) .sidebar-team-avatar {
  background: #473553;
  color: #f6cda9;
}

.sidebar-item > svg { color: var(--muted); }

input:not([type="checkbox"], [type="radio"]), textarea, select, .form-input {
  border-color: var(--border-strong);
  background-color: var(--surface-sunken);
}

input::placeholder, textarea::placeholder { color: var(--muted); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--highlight); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23d1c8ff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.avatar-choice { background: var(--surface-sunken); color: var(--ink); }
.avatar-choice:hover { border-color: var(--border-strong); }

.choice-chip:is([aria-pressed="true"], [aria-selected="true"], .is-selected, :has(input:checked)),
.avatar-choice:is([aria-pressed="true"], [aria-selected="true"], .is-selected, :has(input:checked)) {
  border-color: var(--highlight);
  background: var(--surface-active);
  color: var(--ink);
  box-shadow: none;
}

.segmented-control { background: var(--surface-sunken); }
.segmented-control > :is(label, button):is([aria-pressed="true"], .is-selected, :has(input:checked)) {
  border-color: var(--highlight);
  background: var(--surface-active);
  color: var(--ink);
}

.toast {
  border-color: var(--highlight);
  background: var(--surface-active);
  color: var(--ink);
  box-shadow: 0 8px 26px #080b1b8c;
}

.auth-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .55rem;
  margin-block: .8rem;
  color: var(--muted);
  font-size: .9rem;
}

.auth-fields { min-width: 0; }
.auth-account-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .86rem; }

.avatar-upload {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .42rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--small-radius);
  background: var(--bg);
  padding: .5rem .6rem;
}

.avatar-upload-actions, .avatar-upload-preview {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: .4rem .55rem;
}

.avatar-upload-actions { flex-wrap: wrap; }

.avatar-upload-preview :is(.avatar, img:only-child) {
  width: 2.56rem;
  height: 2.56rem;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  object-fit: cover;
}

.avatar-upload-preview .avatar img {
  width: 100%;
  height: 100%;
  border: 0;
}

.avatar-upload-preview .form-hint { overflow-wrap: anywhere; }

.avatar-upload > :is(.form-hint, .form-error),
.avatar-upload-hint, .avatar-upload-error {
  flex: 1 0 100%;
  overflow-wrap: anywhere;
}

.avatar-upload-status:empty { position: absolute; }

.avatar-upload input.avatar-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  overflow: hidden;
  clip-path: inset(50%);
  margin: -1px;
  border: 0;
  padding: 0;
  white-space: nowrap;
}

.avatar-upload-actions label.button { cursor: pointer; }
.avatar-upload:has(.avatar-file-input:focus-visible) .avatar-upload-actions label.button {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.avatar-upload:has(.avatar-file-input[aria-invalid="true"]) .avatar-upload-actions label.button {
  border-color: var(--danger);
}

.telegram-field .form-input { width: 100%; }
.telegram-field .form-hint { max-width: 48ch; }

.role-search { width: 100%; }
.role-groups {
  display: grid;
  max-height: 15rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  align-content: start;
  gap: .28rem;
  border: 1px solid var(--border);
  border-radius: var(--small-radius);
  background: var(--surface-sunken);
  padding: .32rem;
}

.role-group {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: var(--small-radius);
  background: var(--surface);
}

.role-group[open] { border-color: var(--border); }
.role-group-label {
  border-radius: var(--small-radius);
  color: var(--ink);
  padding: .42rem .56rem;
  font-size: .89rem;
  font-weight: 800;
  cursor: pointer;
}

.role-group-label:focus-visible { outline-offset: -2px; }
.role-group .choice-list { padding: .12rem .52rem .52rem; }
.role-group .choice-chip { min-height: 2rem; padding: .25rem .55rem; }
.role-selected { display: flex; flex-wrap: wrap; gap: .3rem; }
.role-empty { color: var(--muted); padding: .32rem .5rem; font-size: .9rem; }

.messages-layout {
  display: grid;
  height: min(43rem, max(32rem, calc(100dvh - 13rem)));
  min-height: 0;
  grid-template-columns: minmax(16rem, 21.5rem) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface);
}

.messages-inbox {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-inline-end: 1px solid var(--line);
  background: var(--surface);
}

.messages-inbox-body {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.messages-inbox-body > :is(.form-error, .conversation-more) { margin: .45rem .85rem; }

.conversation-item {
  display: grid;
  width: 100%;
  min-height: 4.85rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .64rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: .75rem .85rem;
  text-align: start;
}

.conversation-item:is(:hover, [aria-current="true"], [aria-current="page"]) { background: var(--surface-active); }
.conversation-item:is([aria-current="true"], [aria-current="page"]) { box-shadow: inset 3px 0 var(--highlight); }
.conversation-item:focus-visible { outline-offset: -3px; }

.conversation-avatar {
  display: inline-grid;
  width: 2.44rem;
  height: 2.44rem;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-active);
  color: var(--green-dark);
  font-weight: 800;
}

.conversation-avatar img, img.conversation-avatar { width: 100%; height: 100%; object-fit: cover; }
img.conversation-avatar { width: 2.44rem; height: 2.44rem; }

.conversation-desc { display: grid; min-width: 0; gap: .1rem; }

.conversation-title, .conversation-subject, .conversation-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title { color: var(--ink); font-size: .92rem; font-weight: 800; }
.conversation-subject { color: var(--muted-strong); font-size: .82rem; font-weight: 700; }
.conversation-preview { color: var(--muted); font-size: .81rem; }
.conversation-meta { display: grid; align-self: start; justify-items: end; gap: .3rem; }

.conversation-date, .message-time {
  color: var(--muted);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.conversation-unread {
  display: inline-grid;
  min-width: 1.35rem;
  min-height: 1.35rem;
  place-items: center;
  border-radius: 1rem;
  background: var(--highlight);
  color: var(--accent-ink);
  padding-inline: .25rem;
  font-size: .74rem;
  font-weight: 800;
}

.message-thread {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface-sunken);
}

.message-thread-header {
  display: flex;
  min-height: 4.5rem;
  align-items: center;
  gap: .72rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: .72rem clamp(.8rem, 2vw, 1.2rem);
}

.message-peer {
  min-width: 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.message-subject { color: var(--muted); font-size: .84rem; font-weight: 600; }
.message-back { display: none; }

.message-history {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: auto;
  overscroll-behavior: contain;
}

.message-history:focus-visible { outline-offset: -2px; }
.message-history-actions { flex: none; align-self: center; padding: .55rem .85rem 0; }
.message-history-actions:empty { display: none; }

.message-list {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: .65rem;
  margin: 0;
  padding: 1rem clamp(.85rem, 3vw, 1.65rem);
  list-style: none;
}

.message-list > :first-child { margin-top: auto; }

.message-bubble {
  max-width: min(85%, 35rem);
  flex: none;
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: .68rem .68rem .68rem .18rem;
  background: var(--surface);
  color: var(--ink);
  padding: .56rem .72rem .49rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.message-bubble.is-own {
  align-self: flex-end;
  border-color: #6a5d9a;
  border-radius: .68rem .68rem .18rem .68rem;
  background: #302a54;
}

.message-bubble p { white-space: pre-wrap; }
.message-time { display: block; margin-top: .23rem; text-align: end; }

.message-empty {
  display: grid;
  min-width: 0;
  align-content: center;
  justify-items: center;
  gap: .38rem;
  color: var(--muted);
  padding: 1.3rem;
  text-align: center;
}

.message-empty :is(h2, h3, strong) { color: var(--ink); }
.message-list > .message-empty { width: 100%; margin-block: auto; }
.message-thread > .message-empty:only-child { grid-row: 1 / -1; }

.messages-gate {
  display: grid;
  min-height: 17.5rem;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface);
}

.messages-gate .button { margin-top: .2rem; }

.message-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .35rem .6rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: .72rem clamp(.75rem, 2.3vw, 1.12rem);
}

.message-input-label { grid-column: 1 / -1; color: var(--muted-strong); font-size: .82rem; font-weight: 750; }

.message-composer textarea.form-input {
  display: block;
  width: 100%;
  min-height: 3rem;
  max-height: 9rem;
  resize: vertical;
}

.message-composer .button { min-height: 3rem; }
.message-composer .message-error { grid-column: 1 / -1; }

.site-footer { border-top-color: var(--border); background: var(--surface-sunken); }
.footer-inner :is(strong, a) { color: var(--ink); }
.footer-inner .brand-name { font-size: 1.03rem; }

@media (max-width: 65rem) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr) minmax(15.5rem, 17.3rem); }
  .sidebar-meta { row-gap: .1rem; }
}

@media (max-width: 53rem) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .team-sidebar { display: block; }
  .sidebar-controls .button { width: auto; }
  .nav-link { padding-inline: .6rem; }
  .nav-link:is([aria-current="page"], [aria-selected="true"], .active, .is-active)::after { inset-inline: .6rem; }

  .messages-layout {
    height: min(43rem, max(25rem, calc(100dvh - 12rem)));
    grid-template-columns: minmax(0, 1fr);
  }
  .messages-inbox { border-inline-end: 0; }
  .messages-layout:not(.has-active-thread) .message-thread { display: none; }
  .messages-layout.has-active-thread .messages-inbox { display: none; }
  .message-thread-header { flex-wrap: wrap; row-gap: .25rem; }
  .message-back { display: inline-flex; font-size: .84rem; }
}

@media (max-width: 47rem) {
  .header-inner {
    min-height: 0;
    grid-template-columns: 1fr 1fr;
    gap: 0 .7rem;
    padding-top: .5rem;
  }
  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: .35rem;
    padding-bottom: .36rem;
  }
  .nav-link { min-width: 0; flex: 1 1 auto; }
}

@media (max-width: 40rem) {
  .header-inner { min-height: 0; padding-top: .49rem; }
  .brand-mark { width: 2.18rem; height: 2.18rem; }
  .brand-name { font-size: 1.18rem; }
  .main-nav { gap: .13rem; }
  .nav-link { min-height: 2.38rem; gap: .28rem; padding-inline: .3rem; font-size: .78rem; }
  .nav-link svg { width: .9rem; height: .9rem; }
  .header-actions .icon-button, .header-actions .profile-button { min-height: 2.48rem; }
  .site-main { padding-top: 1.02rem; padding-bottom: 2.55rem; }
  .dashboard-grid { gap: 1.75rem; }
  .news-body { padding-inline: .77rem; }
  .message-composer { grid-template-columns: minmax(0, 1fr) auto; }
  .message-composer .button { padding-inline: .62rem; font-size: .83rem; }
}

@media (max-width: 31rem) {
  .news-cover { min-height: 9.45rem; }
  .news-body { padding-inline: .92rem; }
  .sidebar-controls .button { width: 100%; }
  .avatar-upload-actions { flex-basis: 100%; }
  .avatar-upload-actions .text-button { padding-inline: .45rem; }
  .message-bubble { max-width: 92%; }
}

@media (max-width: 23rem) {
  .nav-link svg { display: none; }
  .nav-link :is(.nav-unread, [data-chat-unread]) { min-width: 1rem; }
}
