/* ==========================================================================
   Запрудный RP — стили форума
   ========================================================================== */

:root {
  --accent:        #ffa500;
  --accent-600:    #f09300;
  --accent-700:    #d97f00;
  --accent-soft:   #fff4e0;
  --accent-ring:   rgba(255, 165, 0, .28);

  --bg:            #e7e9ee;
  --bg-2:          #dee1e8;
  --surface:       #ffffff;
  --surface-2:     #f5f6f9;
  --surface-3:     #eceef3;
  --border:        #e0e3ea;
  --border-strong: #cfd4de;

  --text:          #1d2839;
  --text-2:        #4a5567;
  --muted:         #78828f;
  --link:          #e08700;
  --link-hover:    #b96f00;
  --blue:          #3b6fd4;
  --green:         #2f9e5f;
  --red:           #d9453d;
  --violet:        #7c5cd6;

  --shadow-sm: 0 1px 2px rgba(24, 32, 48, .06);
  --shadow:    0 1px 3px rgba(24, 32, 48, .07), 0 8px 24px rgba(24, 32, 48, .06);
  --shadow-lg: 0 24px 60px rgba(24, 32, 48, .22);

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --page: 1180px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --accent-soft: rgba(255, 165, 0, .13);
  --bg:            #16181d;
  --bg-2:          #101216;
  --surface:       #212429;
  --surface-2:     #1a1d22;
  --surface-3:     #2a2e35;
  --border:        #2d313a;
  --border-strong: #3a3f4a;

  --text:          #e8eaee;
  --text-2:        #bcc3cd;
  --muted:         #8b94a1;
  --link:          #ffb733;
  --link-hover:    #ffc65c;
  --blue:          #6f9bf0;
  --green:         #55c98a;
  --red:           #f2706a;
  --violet:        #a48cf0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 1px 3px rgba(0, 0, 0, .45), 0 10px 28px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

/* Плавную прокрутку включаем скриптом и только если пользователь её не отключил.
   В CSS её нет намеренно: свойство из CSS перебивает behavior:'auto' в scrollTo. */

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-2);
  background-image:
    radial-gradient(1100px 500px at 12% -8%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    radial-gradient(900px 420px at 88% 0%, color-mix(in srgb, var(--blue) 10%, transparent), transparent 62%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
p { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }
img { max-width: 100%; }

svg { width: 1em; height: 1em; display: block; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--r) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ============================ Шапка ============================ */

.topbar {
  position: sticky; top: 0; z-index: 40;
  padding: 12px 16px 0;
}

.topbar-inner {
  max-width: var(--page);
  margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  height: 58px; padding: 0 12px 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(145deg, #ffc043, var(--accent) 55%, var(--accent-700));
  display: grid; place-items: center;
  box-shadow: 0 3px 10px var(--accent-ring);
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text {
  font-weight: 800; font-size: 15px; letter-spacing: .06em;
  color: var(--text); font-style: italic; white-space: nowrap;
}
.brand-text i { font-style: normal; color: var(--accent); margin-left: 5px; font-weight: 700; }
.brand-text.small { font-size: 13px; }

.topnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow: visible; }

.nav-item, .usermenu { position: relative; }

.nav-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 12px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text);
  font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.nav-btn svg { font-size: 17px; color: var(--text-2); }
.nav-btn:hover { background: var(--surface-3); }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn.active svg { color: #fff; }
.nav-btn .chev { width: 12px; height: 12px; opacity: .55; transition: transform .16s; }
.nav-item.open .nav-btn { background: var(--surface-3); }
.nav-item.open .chev { transform: rotate(180deg); }

.menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50;
  min-width: 230px; padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  animation: pop .13s ease-out;
}
.menu.right { left: auto; right: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-5px) scale(.985); } }

.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 14px;
  text-align: left; cursor: pointer; text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--surface-3); text-decoration: none; }
.menu a svg, .menu button svg { font-size: 17px; color: var(--muted); flex-shrink: 0; }
.menu a .count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
.menu-title { padding: 8px 11px 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.iconbtn {
  width: 34px; height: 34px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-2);
  display: grid; place-items: center; cursor: pointer;
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { background: var(--surface-3); color: var(--text); }

html[data-theme="light"] .i-moon,
html[data-theme="dark"]  .i-sun { display: none; }

.user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px 0 4px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.user-pill:hover { background: var(--surface-3); }
.user-pill .chev { width: 11px; height: 11px; opacity: .5; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: hsl(var(--hue, 40) 62% 45%);
  color: #fff; font-weight: 800; font-size: 13px; text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  user-select: none;
}
.avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.avatar.xl { width: 84px; height: 84px; font-size: 34px; border-radius: 26px; }
.avatar.rounded { border-radius: 26px; }

/* ============================ Подшапка ============================ */

.subbar {
  max-width: var(--page); margin: 10px auto 0; padding: 0 16px;
}
.subbar-inner {
  display: flex; align-items: center; gap: 10px; min-height: 42px;
  padding: 6px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { color: var(--text-2); font-weight: 500; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .45; }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 9px 14px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--text-2); text-decoration: none; white-space: nowrap;
}
.tabs a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--accent); color: #fff; }

/* ============================ Каркас страницы ============================ */

.page {
  flex: 1;
  width: 100%; max-width: var(--page);
  margin: 0 auto; padding: 22px 16px 40px;
}

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 312px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }

.stack { display: grid; gap: 18px; }
.side  { display: grid; gap: 18px; position: sticky; top: 88px; }
@media (max-width: 1000px) { .side { position: static; } }

.page-title { font-size: 26px; margin-bottom: 14px; letter-spacing: -.02em; }
.page-lead { color: var(--text-2); margin-bottom: 18px; max-width: 72ch; }

/* ============================ Карточки ============================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: 17px; }
.card-head .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.section-title {
  font-size: 19px; margin: 4px 0 12px;
}
.section-title.accent { color: var(--accent); }

/* ============================ Список разделов / тем ============================ */

.rows { display: flex; flex-direction: column; }

.row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 14px; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background .13s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }

.row-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border);
}
.row-icon svg { width: 21px; height: 21px; }
.row-icon.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.row-main { min-width: 0; }
.row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-title a { font-size: 15.5px; font-weight: 600; color: var(--text); }
.row-title a:hover { color: var(--accent); }
.row-excerpt {
  font-size: 13.5px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted); margin-top: 5px;
}
.row-meta .who { color: var(--text-2); font-weight: 500; }
.row-meta .who:hover { color: var(--accent); }

.row-stats { display: flex; gap: 20px; text-align: right; font-size: 12.5px; color: var(--muted); }
.row-stats b { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.row-stats > div { min-width: 52px; }

.row-last { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); text-align: right; }
.row-last b { display: block; color: var(--text-2); font-size: 13px; font-weight: 600; }
.row-last a { color: var(--text); font-weight: 600; }
.row-last a:hover { color: var(--accent); }

@media (max-width: 760px) {
  .row { grid-template-columns: 44px minmax(0, 1fr); }
  .row-stats, .row-last { grid-column: 2; justify-content: flex-start; text-align: left; }
  .row-last .avatar { display: none; }
}

.ico-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* ============================ Бейджи ============================ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.badge svg { font-size: 12px; }
.badge.accent   { background: var(--accent-soft); color: var(--accent-700); }
.badge.green    { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.badge.red      { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.badge.blue     { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.badge.violet   { background: color-mix(in srgb, var(--violet) 15%, transparent); color: var(--violet); }
.badge.pinned   { background: var(--accent); color: #fff; }
.badge.locked   { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }

.role-user       { color: var(--muted); }
.role-moderator  { color: var(--blue); }
.role-admin      { color: var(--violet); }
.role-head_admin { color: var(--accent); }

/* ============================ Кнопки ============================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 10px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: filter .13s, background .13s, border-color .13s;
}
.btn svg { font-size: 17px; }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 10px var(--accent-ring); }
.btn-primary:hover { background: var(--accent-600); }
.btn-ghost   { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-soft    { background: var(--accent-soft); color: var(--accent-700); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-danger  { background: var(--red); color: #fff; }
.btn-sm      { height: 32px; padding: 0 13px; font-size: 13.5px; border-radius: 8px; }
.btn-block   { width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ============================ Формы ============================ */

.form-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px 20px; align-items: start;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.form-row:last-child { border-bottom: 0; }
.form-row > label { text-align: right; padding-top: 9px; }
.form-row > label .req { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.form-row > label b { font-weight: 600; font-size: 14.5px; }
.form-ctl { min-width: 0; }
.form-ctl .help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
@media (max-width: 720px) {
  .form-row { grid-template-columns: 1fr; gap: 8px; }
  .form-row > label { text-align: left; padding-top: 0; }
}

input[type="text"], input[type="password"], input[type="number"],
input[type="search"], input[type="email"], select, textarea {
  width: 100%; padding: 9px 12px;
  font: inherit; font-size: 14.5px; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 9px;
  transition: border-color .13s, box-shadow .13s, background .13s;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; background: var(--surface);
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
select { cursor: pointer; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 92px; }
.input-wrap .btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  height: 30px; padding: 0 11px; font-size: 13px;
}

.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 14px; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }

.field-error { color: var(--red); font-size: 12.5px; margin-top: 6px; font-weight: 500; }
.input-invalid { border-color: var(--red) !important; }

/* ============================ Модальные окна ============================ */

.modal-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 26, 36, .55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 22px;
  animation: fade .14s ease-out;
  overflow-y: auto;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: min(720px, 100%);
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise .18s cubic-bezier(.2, .8, .3, 1);
  max-height: calc(100vh - 44px);
  display: flex; flex-direction: column;
}
.modal.sm { width: min(480px, 100%); }
.modal.lg { width: min(920px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 22px;
  background: var(--accent); color: #fff;
}
.modal-head h3 { font-size: 21px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .16); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.modal-close:hover { background: rgba(255, 255, 255, .3); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 15px 22px; border-top: 1px solid var(--border); background: var(--surface-2);
}

.modal-note {
  margin: -4px 0 16px; padding: 10px 12px;
  background: var(--surface-3); border-radius: 9px;
  font-size: 13px; color: var(--text-2);
}

/* ============================ Уведомления ============================ */

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 120;
  display: grid; gap: 10px; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  font-size: 14px; animation: slidein .2s ease-out;
}
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }
.toast.error { border-left-color: var(--red); }
.toast.ok    { border-left-color: var(--green); }
.toast svg { font-size: 18px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.toast.error svg { color: var(--red); }
.toast.ok svg { color: var(--green); }

/* ============================ Правила ============================ */

.rules-nav {
  position: sticky; top: 88px;
  display: grid; gap: 3px;
  padding: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.rules-nav a {
  display: flex; gap: 9px; align-items: baseline;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
}
.rules-nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.rules-nav a.active { background: var(--accent); color: #fff; }
.rules-nav .num { font-size: 12px; opacity: .7; min-width: 14px; }

.rules-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 940px) {
  .rules-layout { grid-template-columns: 1fr; }
  .rules-nav { position: static; grid-auto-flow: column; overflow-x: auto; }
  .rules-nav a { white-space: nowrap; }
}

.rule-section { scroll-margin-top: 92px; }
.rule-section + .rule-section { margin-top: 20px; }

.rule-article { padding: 18px; border-bottom: 1px solid var(--border); }
.rule-article:last-child { border-bottom: 0; }
.rule-article h4 {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 16px; margin-bottom: 9px;
}
.rule-num {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 24px; padding: 0 7px;
  background: var(--accent); color: #fff;
  border-radius: 7px; font-size: 12.5px; font-weight: 800;
}
.rule-article p { color: var(--text-2); }

.rule-lead {
  padding: 11px 14px; margin-bottom: 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent); border-radius: 0 9px 9px 0;
  font-weight: 600; color: var(--text) !important;
}

.rule-list { margin: 12px 0 0; }
.rule-list-label {
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent-700); margin: 14px 0 6px;
}
html[data-theme="dark"] .rule-list-label { color: var(--accent); }
.rule-list ul { margin: 0; padding-left: 20px; }
.rule-list li { margin-bottom: 5px; color: var(--text-2); }
.rule-list li::marker { color: var(--accent); }

.rule-note {
  margin-top: 12px; padding: 11px 13px;
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  border-radius: 9px; font-size: 13.5px; color: var(--text-2);
}

/* ============================ Виджеты сайдбара ============================ */

.widget-news { display: grid; }
.news-item { display: flex; gap: 11px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: 0; }
.news-icon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
}
.news-icon svg { width: 17px; height: 17px; }
.news-item.accent .news-icon { background: var(--accent-soft); color: var(--accent); }
.news-item h4 { font-size: 14px; line-height: 1.35; margin-bottom: 4px; }
.news-item p { font-size: 13px; color: var(--muted); margin: 0; }
.news-date { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: right; }

.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row span { color: var(--muted); }
.stat-row b { font-size: 15px; }

.member { display: flex; align-items: center; gap: 11px; padding: 9px 0; }
.member + .member { border-top: 1px solid var(--border); }
.member-name { font-size: 14px; font-weight: 600; color: var(--text); }
.member-name:hover { color: var(--accent); }
.member-meta { font-size: 12.5px; color: var(--muted); }

/* ============================ Тема ============================ */

.post { display: grid; grid-template-columns: 168px minmax(0, 1fr); }
.post + .post { border-top: 1px solid var(--border); }

.post-side {
  padding: 18px 16px; text-align: center;
  background: var(--surface-2); border-right: 1px solid var(--border);
}
.post-side .avatar { margin: 0 auto 9px; }
.post-side .name { font-weight: 700; font-size: 14.5px; word-break: break-word; }
.post-side .nick { font-size: 12.5px; color: var(--muted); word-break: break-word; }
.post-side .role { margin-top: 7px; }
.post-side .stats { margin-top: 12px; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.post-side .stats b { color: var(--text-2); }

.post-main { padding: 18px 20px; min-width: 0; }
.post-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
.post-body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.post-body a { word-break: break-all; }

@media (max-width: 640px) {
  .post { grid-template-columns: 1fr; }
  .post-side {
    display: flex; align-items: center; gap: 12px; text-align: left;
    border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 16px;
  }
  .post-side .avatar { margin: 0; }
  .post-side .stats { display: none; }
}

/* ============================ Профиль ============================ */

.profile-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; padding: 22px; }
.profile-info h1 { font-size: 25px; }
.profile-info .role-line { margin-top: 6px; font-size: 14.5px; }
.profile-activity { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.profile-activity b { color: var(--text-2); font-weight: 600; }
.profile-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 22px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.profile-pills { display: flex; gap: 8px; }
.pill {
  min-width: 74px; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; text-align: center;
}
.pill span { display: block; font-size: 11.5px; color: var(--muted); }
.pill b { font-size: 17px; }

@media (max-width: 620px) {
  .profile-head { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .profile-bottom { flex-direction: column; }
}

.settings-layout { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .settings-layout { grid-template-columns: 1fr; } }

.sidenav { padding: 8px; }
.sidenav-title {
  padding: 9px 11px 7px; font-size: 11.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.sidenav a, .sidenav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 14px;
  text-align: left; cursor: pointer; text-decoration: none;
}
.sidenav a svg, .sidenav button svg { font-size: 17px; color: var(--muted); flex-shrink: 0; }
.sidenav a:hover, .sidenav button:hover { background: var(--surface-3); text-decoration: none; }
.sidenav a.active { background: var(--accent); color: #fff; }
.sidenav a.active svg { color: #fff; }
.sidenav hr { border: 0; border-top: 1px solid var(--border); margin: 7px 6px; }

.settings-main {
  padding: 16px 22px 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}

/* ============================ Профиль меню (как в референсе) ============================ */

.usermenu-head { display: flex; gap: 14px; padding: 14px; border-bottom: 1px solid var(--border); }
.usermenu-head .info { min-width: 0; }
.usermenu-head .name { font-weight: 700; font-size: 16px; }
.usermenu-head .sub { font-size: 13px; color: var(--muted); }
.usermenu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 8px; }
.usermenu-grid .wide { grid-column: 1 / -1; }
.usermenu-grid a, .usermenu-grid button {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 13.5px;
  text-align: left; cursor: pointer; text-decoration: none;
}
.usermenu-grid a:hover, .usermenu-grid button:hover { background: var(--surface-3); text-decoration: none; }
.usermenu-grid svg { font-size: 16px; color: var(--muted); }

/* ============================ Тест / заявка ============================ */

.quiz { display: grid; gap: 16px; }
.quiz-q { padding: 20px; }
.quiz-q + .quiz-q { border-top: 1px solid var(--border); }
.quiz-code {
  display: inline-block; margin-bottom: 8px; padding: 2px 9px;
  background: var(--surface-3); color: var(--muted);
  border-radius: 999px; font-size: 11.5px; font-weight: 800;
}
.quiz-q h4 { font-size: 15.5px; margin-bottom: 6px; }
.quiz-hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

.opts { display: grid; gap: 8px; margin-top: 12px; }
.opt {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border); border-radius: var(--r);
  cursor: pointer; font-size: 14.5px; color: var(--text-2);
  transition: border-color .13s, background .13s;
}
.opt:hover { border-color: var(--accent); background: var(--surface); }
.opt input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 500; }
.opt.ok   { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); }
.opt.bad  { border-color: var(--red); background: color-mix(in srgb, var(--red) 9%, transparent); }
.opt.locked { cursor: default; }
.opt-mark { margin-left: auto; font-size: 18px; display: none; }
.opt.ok .opt-mark { display: block; color: var(--green); }
.opt.bad .opt-mark { display: block; color: var(--red); }
.opt-explain {
  margin-top: 9px; padding: 10px 12px; font-size: 13.5px;
  background: var(--surface-2); border-left: 3px solid var(--border-strong);
  border-radius: 0 8px 8px 0; color: var(--text-2);
}
.opt-explain.ok { border-left-color: var(--green); }
.opt-explain.bad { border-left-color: var(--red); }

.progress {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.progress-bar { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-600), var(--accent)); border-radius: 999px; transition: width .3s; }
.progress .num { font-size: 13.5px; font-weight: 700; white-space: nowrap; }

.score-big { text-align: center; padding: 26px 18px; }
.score-big .n { font-size: 46px; font-weight: 800; line-height: 1; color: var(--accent); }
.score-big .t { font-size: 15px; color: var(--text-2); margin-top: 8px; }

/* ============================ Админка ============================ */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.kpi {
  padding: 15px 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
}
.kpi .v { font-size: 25px; font-weight: 800; line-height: 1.1; }
.kpi .l { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.kpi.accent .v { color: var(--accent); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 11px 14px; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.answer-block { padding: 14px 0; border-bottom: 1px solid var(--border); }
.answer-block:last-child { border-bottom: 0; }
.answer-block .q { font-weight: 700; font-size: 14.5px; margin-bottom: 7px; }
.answer-block .a { white-space: pre-wrap; color: var(--text-2); background: var(--surface-2); padding: 11px 13px; border-radius: 9px; }
.answer-block .correct { font-size: 13px; color: var(--green); margin-top: 7px; }
.answer-block .incorrect { font-size: 13px; color: var(--red); margin-top: 7px; }

/* ============================ Разное ============================ */

.empty { padding: 40px 22px; text-align: center; color: var(--muted); }
.empty svg { font-size: 40px; margin: 0 auto 12px; opacity: .4; display: block; }
.empty h4 { font-size: 16px; color: var(--text-2); margin-bottom: 6px; }

.loading { padding: 44px; text-align: center; color: var(--muted); }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--r);
  background: var(--accent-soft); color: var(--text); font-size: 14px;
}
.notice svg { font-size: 19px; color: var(--accent); flex-shrink: 0; }
.notice.error { background: color-mix(in srgb, var(--red) 11%, transparent); }
.notice.error svg { color: var(--red); }
.notice.green { background: color-mix(in srgb, var(--green) 11%, transparent); }
.notice.green svg { color: var(--green); }

.footer { margin-top: auto; background: var(--surface); border-top: 1px solid var(--border); }
.footer-inner {
  max-width: var(--page); margin: 0 auto; padding: 26px 16px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 22px;
}
.footer-col h4 { font-size: 13px; margin-bottom: 9px; }
.footer-col p { font-size: 13px; color: var(--muted); margin-top: 8px; }
.footer-col a { display: block; font-size: 13.5px; padding: 3px 0; color: var(--text-2); }
.footer-col a:hover { color: var(--accent); }
.footer-col span { font-size: 13.5px; color: var(--muted); }
.footer-bottom {
  border-top: 1px solid var(--border); padding: 13px 16px; text-align: center;
  font-size: 12.5px; color: var(--muted);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt   { margin-top: 16px; }
.mt-s { margin-top: 9px; }
.mb   { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }
