:root {
  --bg: #F2F2F2;
  --surface: #FFFFFF;
  --surface-2: #F7F6F5;
  --text: #111111;
  --text-2: #5C5C5C;
  --border: #E4E2E0;
  --brand: #D3132C;
  --brand-hover: #B30F25;
  --brand-text: #C01128;
  --brand-soft: #FBE7EA;
  --ok: #1B8A66;
  --ok-soft: #E2F4EC;
  --info: #0B6E8E;
  --info-soft: #E3F5FC;
  --chip: #EDEBE9;
  --focus: #8AD9F1;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font-display: "Unbounded", "Druk Wide Cyr", arial, sans-serif;
  --font-body: "Inter", arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F0F10;
    --surface: #1A1A1C;
    --surface-2: #222225;
    --text: #F2F2F2;
    --text-2: #A3A3A8;
    --border: #2E2E32;
    --brand-hover: #E5243B;
    --brand-text: #FF6B7D;
    --brand-soft: rgba(255,61,85,.14);
    --ok: #4BD3A6;
    --ok-soft: rgba(60,203,159,.14);
    --info: #8AD9F1;
    --info-soft: rgba(138,217,241,.12);
    --chip: #2A2826;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F0F10;
  --surface: #1A1A1C;
  --surface-2: #222225;
  --text: #F2F2F2;
  --text-2: #A3A3A8;
  --border: #2E2E32;
  --brand-hover: #E5243B;
  --brand-text: #FF6B7D;
  --brand-soft: rgba(255,61,85,.14);
  --ok: #4BD3A6;
  --ok-soft: rgba(60,203,159,.14);
  --info: #8AD9F1;
  --info-soft: rgba(138,217,241,.12);
  --chip: #2A2826;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-padding-top: 80px; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.icon { width: 18px; height: 18px; flex: none; }
.icon--sm { width: 14px; height: 14px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top__inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__mark { font: 700 17px/1 var(--font-display); letter-spacing: .01em; white-space: nowrap; }
.brand__mark span { color: var(--brand); }
.brand__product { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; color: var(--text);
}
.icon-btn:hover { border-color: var(--text-2); }
.inbox {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 18px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.inbox:hover { text-decoration: none; border-color: var(--text-2); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-size: 12px; font-variant-numeric: tabular-nums;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--chip); color: var(--text); font-weight: 600; font-size: 13px; flex: none;
}
.avatar--me { background: var(--brand); color: #fff; }
.avatar--lg { width: 40px; height: 40px; font-size: 15px; }

.menu { position: relative; }
.menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; font-size: 14px; border-radius: 18px; padding: 2px 8px 2px 2px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary, .menu > summary:hover { background: var(--surface-2); }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12); padding: 6px; z-index: 20;
}
.menu__item {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text); background: none; border: 0; cursor: pointer; font-size: 14px; text-align: left;
}
.menu__item:hover { background: var(--surface-2); text-decoration: none; }
.menu__meta { padding: 8px 10px; font-size: 12px; color: var(--text-2); border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* layout */
.layout {
  max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px;
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px;
}
.nav { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
.nav__title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 16px 12px 6px; }
.nav__title:first-child { margin-top: 0; }
.nav__list { list-style: none; margin: 0; padding: 0; }
.nav__item a {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 7px 12px; border-radius: 8px; color: var(--text); font-size: 14px;
}
.nav__item a:hover { background: var(--surface); text-decoration: none; }
.nav__item--active a { background: var(--surface); font-weight: 600; box-shadow: var(--shadow); }
.nav__count { color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 400; white-space: nowrap; }

/* page head */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head__text { flex: 1 1 320px; }
h1 { font: 700 28px/1.15 var(--font-display); letter-spacing: -.01em; margin: 0 0 8px; }
.stats { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 14px; }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.lead { color: var(--text-2); margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 8px;
  border: 1px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-hover); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { border-color: var(--text-2); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }

/* list navigation */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px;
  color: var(--text-2); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--brand); }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 500;
}
.filter:hover { text-decoration: none; border-color: var(--text-2); }
.filter[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.search { margin-left: auto; display: flex; gap: 8px; flex: 0 1 280px; }
.search input { flex: 1; min-width: 0; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); }
.active-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--text-2); }
.chip-x {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 12px; border-radius: 14px;
  background: var(--chip); color: var(--text); font-weight: 500;
}
.chip-x:hover { text-decoration: none; }
.chip-x .icon { width: 14px; height: 14px; opacity: .6; }

/* feed */
.feed { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; box-shadow: var(--shadow); }
.feed__title { font: 600 13px/1.4 var(--font-body); text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 0 0 6px; }
.feed__list { list-style: none; margin: 0; padding: 0; }
.feed__item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--border); font-size: 14px; }
.feed__item:first-child { border-top: 0; }
.feed__item .avatar { width: 24px; height: 24px; font-size: 11px; align-self: center; }
.feed__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__time { color: var(--text-2); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* section */
.section { margin-top: 28px; }
.section:first-of-type { margin-top: 8px; }
.section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
h2 { font: 600 18px/1.3 var(--font-display); margin: 0; }
.section__meta { color: var(--text-2); font-size: 13px; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; padding: 32px 16px; text-align: center; color: var(--text-2); }

/* question card */
.q {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); margin-bottom: 8px; color: var(--text);
}
a.q:hover { text-decoration: none; border-color: var(--text-2); }
.q__row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; padding: 16px; }
.q__num {
  min-width: 44px; height: 28px; padding: 0 6px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--chip); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums;
}
.q__text { margin: 2px 0 10px; }
.q__text--lg { font-size: 17px; line-height: 1.5; }
.q__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 24px; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.pill--blocker { background: var(--brand-soft); color: var(--brand-text); }
.pill--answered { background: var(--ok-soft); color: var(--ok); }
.pill--partial { background: var(--info-soft); color: var(--info); }
.pill--open { background: var(--chip); color: var(--text-2); }
.pill--person { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.pill--to-me { background: var(--brand); color: #fff; border-color: var(--brand); }
.q__comments { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.q__comments .icon { width: 16px; height: 16px; }

/* question page */
.crumbs { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; font-size: 14px; }
.crumbs__pager { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.q--open { border-color: var(--text-2); }
.q__controls { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font-size: 13px; font-weight: 500; cursor: pointer; border-left: 1px solid var(--border); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.control { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.control select { height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); padding: 0 8px; color: var(--text); }
.thread { border-top: 1px solid var(--border); padding: 16px 16px 16px 76px; background: var(--surface-2); border-radius: 0 0 12px 12px; }
.thread__empty { color: var(--text-2); margin: 0 0 16px; }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
.msg__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.msg__name { font-weight: 600; font-size: 14px; }
.msg__role { color: var(--text-2); }
.msg__time { color: var(--text-2); margin-left: auto; font-variant-numeric: tabular-nums; }
.msg__body { margin: 4px 0 0; overflow-wrap: anywhere; }
.event { font-size: 13px; color: var(--text-2); margin: 0 0 16px 44px; }
.reply textarea, .field textarea, .field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.reply textarea { min-height: 84px; resize: vertical; }
.reply textarea::placeholder, .field input::placeholder { color: var(--text-2); }
.reply__actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); }
.form { display: grid; gap: 16px; max-width: 640px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input, .field select { height: 42px; }
.field textarea { min-height: 120px; resize: vertical; }
.field__help { color: var(--text-2); font-size: 13px; margin: 6px 0 0; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--brand-text); font-size: 13px; font-weight: 500; }
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert--error { background: var(--brand-soft); color: var(--brand-text); }
.alert--ok { background: var(--ok-soft); color: var(--ok); }
.form__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.password { position: relative; }
.password input { padding-right: 44px; }
.password__toggle { position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth__box { width: 100%; max-width: 400px; }
.auth__brand { text-align: center; margin-bottom: 24px; }
.auth__brand .brand__mark { font-size: 22px; }
.auth__brand p { color: var(--text-2); margin: 8px 0 0; font-size: 14px; }
.auth__theme { position: fixed; top: 16px; right: 16px; }

/* people */
.people { display: grid; gap: 8px; }
.person { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; }
.person__name { font-weight: 600; }
.person__role { color: var(--text-2); font-size: 13px; }
.person__links { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.person__links .filter b { font-variant-numeric: tabular-nums; margin-left: 4px; }

/* documents */
.toc { list-style: none; margin: 0 0 24px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px; box-shadow: var(--shadow); }
.doc__body { padding: 20px 24px 8px; }
.doc__body h2 { margin-bottom: 12px; }
.prose h3 { font: 600 15px/1.4 var(--font-body); margin: 20px 0 8px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 4px; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose code { font-size: 13px; background: var(--chip); padding: 1px 5px; border-radius: 4px; }
.doc__thread { border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.doc__thread > summary { cursor: pointer; padding: 12px 24px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.doc__thread[open] > summary { color: var(--text); }
.doc__thread .thread { border-top: 0; padding-left: 24px; padding-top: 4px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 16px; }
  .nav { position: static; max-height: none; overflow: visible; }
  .nav__title { display: none; }
  .nav__lists { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .nav__list { display: contents; }
  .nav__item a { white-space: nowrap; background: var(--surface); border: 1px solid var(--border); }
  .brand__product, .menu__name, .inbox__label { display: none; }
  h1 { font-size: 22px; }
  .thread { padding-left: 16px; }
  .event { margin-left: 0; }
  .search { flex: 1 1 100%; margin-left: 0; }
  .person { grid-template-columns: 40px minmax(0, 1fr); }
  .person__links { grid-column: 1 / -1; justify-content: flex-start; }
  .doc__body { padding: 16px; }
  .doc__thread > summary { padding: 12px 16px; }
  .doc__thread .thread { padding-left: 16px; }
  .crumbs__pager { margin-left: 0; width: 100%; }
}
