/* ==========================================================================
   Мини-форум — стили
   Светлая тема, тёмная шапка, бронзовый акцент. Без внешних зависимостей.
   ========================================================================== */

:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --card-2: #f8f9fb;
  --ink: #232a33;
  --muted: #66707c;
  --line: #e4e8ee;
  --line-strong: #d4dae2;

  --accent: #a4641c;          /* бронза */
  --accent-strong: #8a5212;
  --accent-soft: #f8efe2;
  --header-bg: #22262d;
  --header-ink: #eef1f5;
  --header-accent: #e2b45c;

  --pos: #178a43;
  --pos-soft: #e5f5ea;
  --neg: #b3352c;
  --neg-soft: #fbeae8;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(35, 42, 51, .06), 0 4px 14px rgba(35, 42, 51, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

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

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

.noscript {
  margin: 16px; padding: 14px 18px; background: var(--neg-soft);
  border: 1px solid var(--neg); border-radius: var(--radius);
}

/* ---------- Шапка ---------- */
.site-header {
  background: var(--header-bg);
  color: var(--header-ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  position: sticky; top: 0; z-index: 20;
}
.site-header-inner {
  display: flex; align-items: center; gap: 24px;
  min-height: 62px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--header-accent), #9a7325);
  color: #23262d; font-weight: 800; font-size: 20px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; font-weight: 700; color: #fff; }
.brand-text small { font-size: 11.5px; color: #aab3bd; }

.main-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.main-nav a {
  color: #c3cbd4; padding: 9px 14px; border-radius: 8px;
  font-weight: 600; font-size: 14.5px; text-decoration: none;
}
.main-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); text-decoration: none; }
.main-nav a.active { color: var(--header-accent); background: rgba(226, 180, 92, .12); }

/* ---------- Основное ---------- */
#app { flex: 1; padding: 22px 16px 40px; }

.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: .2px; }
.page-head .muted { font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 18px;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line-strong);
  font-size: 12px; color: var(--muted); vertical-align: middle; white-space: nowrap;
}
.chip.gold { background: var(--accent-soft); border-color: #e5cfa4; color: var(--accent-strong); }
.chip.green { background: var(--pos-soft); border-color: #b7dfc3; color: var(--pos); }
.chip.red { background: var(--neg-soft); border-color: #eec7c3; color: var(--neg); }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff !important; border: 1px solid var(--accent-strong);
  font: 600 13.5px var(--font); cursor: pointer; text-decoration: none !important;
}
.btn:hover { background: var(--accent-strong); }
.btn-ghost {
  background: transparent; color: var(--muted) !important; border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: var(--card-2); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }

/* ---------- Формы ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
input[type="search"], input[type="text"], select {
  font: 14px var(--font); color: var(--ink);
  padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; min-width: 0;
}
input[type="search"] { flex: 1 1 220px; }
input:focus, select:focus { border-color: var(--accent); }
label.f-label { font-size: 13px; color: var(--muted); }

/* ---------- Таблицы ---------- */
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); padding: 8px 12px; border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: #fbf8f3; }
tr.rowlink { cursor: pointer; }

.nick { font-weight: 650; }
.cell-user { display: flex; align-items: center; gap: 9px; }

/* ---------- Аватары ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; flex: 0 0 auto;
  user-select: none; overflow: hidden;
}
.avatar.unknown { background: #98a2ad; }

/* ---------- Пагинация ---------- */
.pager { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.pager a, .pager span {
  min-width: 34px; height: 34px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--ink); text-decoration: none;
}
.pager a:hover { background: var(--accent-soft); border-color: #e5cfa4; text-decoration: none; }
.pager .cur { background: var(--accent); border-color: var(--accent-strong); color: #fff; font-weight: 700; }
.pager .dots { border: 0; }
.pager-info { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------- Дерево разделов ---------- */
.cat-tree, .cat-tree ul { list-style: none; margin: 0; padding: 0; }
.cat-tree ul { margin-left: 8px; padding-left: 18px; border-left: 2px solid var(--line); }
.cat-item { padding: 5px 0; }
.cat-item .cat-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cat-item .cat-title { font-weight: 650; font-size: 15.5px; }
.cat-item .cat-desc { color: var(--muted); font-size: 13px; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cat-cell {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
  background: var(--card-2); display: block; color: var(--ink);
}
.cat-cell:hover { border-color: #e5cfa4; background: var(--accent-soft); text-decoration: none; }
.cat-cell .t { font-weight: 650; display: block; margin-bottom: 3px; color: var(--accent-strong); }
.cat-cell .d { font-size: 12.5px; color: var(--muted); display: block; min-height: 32px; }
.cat-cell .c { font-size: 12px; color: var(--muted); display: block; margin-top: 6px; }

/* ---------- Хлебные крошки ---------- */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 6px; opacity: .6; }
.crumbs .cur { color: var(--ink); }

/* ---------- Посты темы ---------- */
.topic-head { margin-bottom: 4px; }
.topic-head h1 { margin: 0 0 8px; font-size: 23px; line-height: 1.3; }
.topic-meta { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; align-items: center; }

.post {
  display: flex; gap: 14px; padding: 16px 4px 14px;
  border-bottom: 1px solid var(--line);
}
.post:last-child { border-bottom: 0; }
.post-side { width: 120px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.post-side .nick { font-size: 14px; }
.post-main { flex: 1; min-width: 0; }
.post-head { display: flex; gap: 12px; align-items: baseline; color: var(--muted); font-size: 12.5px; margin-bottom: 7px; }
.post-num { font-weight: 700; color: var(--line-strong); }
.post-body { overflow-wrap: break-word; }
.post-body p { margin: 0 0 10px; }
.post-body p:last-child { margin-bottom: 0; }

/* ---------- Реакции ---------- */
details.reactions { margin-top: 12px; font-size: 13px; }
details.reactions > summary { list-style: none; cursor: pointer; color: var(--muted); display: list-item; }
details.reactions > summary::-webkit-details-marker { display: none; }
details.reactions > summary::before {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); margin-right: 8px; transition: transform .15s;
}
details.reactions[open] > summary::before { transform: rotate(45deg); }
details.reactions ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.reaction { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 4px 10px; border-radius: 6px; background: var(--card-2); }
.reaction .sign { font-weight: 800; width: 12px; }
.reaction.pos { background: var(--pos-soft); } .reaction.pos .sign { color: var(--pos); }
.reaction.neg { background: var(--neg-soft); } .reaction.neg .sign { color: var(--neg); }
.reaction .rt { color: var(--ink); }

/* ---------- BB-коды ---------- */
.bb-img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 10px 0; }
.bb-img-link { display: block; }
.bb-quote {
  margin: 10px 0; padding: 0; border-left: 3px solid var(--accent);
  background: #faf6ee; border-radius: 0 6px 6px 0;
}
.bb-quote .bb-quote { margin: 6px 10px 8px; }
.bb-quote-head { padding: 6px 12px 4px; font-size: 12.5px; color: var(--muted); font-style: italic; border-bottom: 1px dashed #e8ddc4; }
.bb-quote-body { padding: 8px 12px 10px; }
pre.bb-code {
  background: #262b33; color: #e8edf4; border-radius: 8px;
  padding: 12px 14px; overflow: auto; margin: 10px 0;
  font: 13px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: break-word;
}
.bb-code code { font: inherit; background: none; padding: 0; }
.bb-badurl { background: var(--neg-soft); border-radius: 4px; padding: 0 5px; color: var(--neg); font-size: .95em; }
ul.bb-list { margin: 8px 0; padding-left: 26px; }
ul.bb-list li { margin: 3px 0; }
.bb-center { text-align: center; margin: 8px 0; }
.bb-spoiler { margin: 8px 0; border: 1px dashed var(--line-strong); border-radius: 6px; padding: 6px 10px; }
.bb-spoiler summary { cursor: pointer; color: var(--muted); font-size: 13px; }
hr.bb-hr { border: 0; border-top: 1px solid var(--line-strong); margin: 14px 0; }

/* ---------- Опросы ---------- */
.poll-card { scroll-margin-top: 90px; }
.poll-card.highlight { outline: 2px solid var(--accent); outline-offset: 3px; }
.poll-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.poll-head h3 { margin: 0; font-size: 18px; }
.poll-topic-line { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.poll-opt { margin: 10px 0; }
.poll-opt-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.poll-opt-title { font-weight: 650; }
.poll-bar { height: 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; }
.poll-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #c9944a, var(--accent)); }
.poll-zero .poll-bar-fill { background: var(--line-strong); }
.voters { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 6px; }
.voter {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px 3px 4px; font-size: 12.5px;
  text-decoration: none; color: var(--ink);
}
.voter:hover { border-color: #e5cfa4; background: var(--accent-soft); text-decoration: none; }
.voter time { color: var(--muted); font-size: 11px; }
.poll-total { margin-top: 12px; color: var(--muted); font-size: 13px; }
details.voters-toggle { margin-top: 7px; font-size: 12.5px; }
details.voters-toggle > summary { cursor: pointer; color: var(--accent); list-style: none; }
details.voters-toggle > summary::-webkit-details-marker { display: none; }

/* ---------- Карточка пользователя ---------- */
.user-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.user-head .un { font-size: 24px; font-weight: 750; margin: 0 0 4px; }
.user-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.user-stats .chip { padding: 5px 12px; font-size: 12.5px; }

.dlg-row { border-bottom: 1px solid var(--line); padding: 10px 0; }
.dlg-row:last-child { border-bottom: 0; }
.dlg-row > details > summary {
  list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.dlg-row > details > summary::-webkit-details-marker { display: none; }
.dlg-row > details > summary::before {
  content: ""; flex: 0 0 auto; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); margin-right: 4px; transition: transform .15s;
}
.dlg-row > details[open] > summary::before { transform: rotate(45deg); }
.dlg-msgs { margin: 12px 0 6px 22px; display: flex; flex-direction: column; gap: 8px; }
.dlg-msg { max-width: 82%; border-radius: 10px; padding: 8px 12px; background: var(--card-2); border: 1px solid var(--line); }
.dlg-msg.out { align-self: flex-end; background: var(--accent-soft); border-color: #ecd9b4; }
.dlg-msg .m-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.dlg-msg .m-text { overflow-wrap: anywhere; }

.upost { border-bottom: 1px solid var(--line); padding: 12px 0; }
.upost:last-child { border-bottom: 0; }
.upost-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; margin-bottom: 6px; }
.upost-title { font-weight: 650; }
.created-topics { list-style: none; margin: 0; padding: 0; }
.created-topics li { padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.created-topics li:last-child { border-bottom: 0; }

/* ---------- Поиск тем ---------- */
.search-results .sr { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.search-results .sr:last-child { border-bottom: 0; }
.sr-line { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; margin-top: 3px; color: var(--muted); font-size: 13px; }
.sr-title { font-weight: 650; font-size: 15.5px; }

/* ---------- Состояния ---------- */
.loading-block, .empty, .error-box {
  text-align: center; color: var(--muted); padding: 34px 16px;
}
.empty .big, .error-box .big { display: block; font-size: 34px; margin-bottom: 8px; color: #b9c1cb; }
.error-box { border: 1px solid #eec7c3; background: var(--neg-soft); border-radius: var(--radius); color: var(--neg); }
.error-box a { color: var(--accent-strong); }

.skeleton { height: 16px; border-radius: 6px; background: linear-gradient(100deg, #edf0f3 40%, #f7f9fa 50%, #edf0f3 60%); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px;
  border: 3px solid rgba(164, 100, 28, .2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Оверлей загрузки/сканирования ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(34, 38, 45, .55);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.overlay.hidden, .hidden { display: none; }
.overlay-box {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 34px; width: min(480px, 92vw); text-align: center;
}
.overlay-text { font-weight: 600; margin-bottom: 4px; }
.overlay-progress { height: 8px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; margin: 10px 0 6px; }
.overlay-progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, #c9944a, var(--accent)); transition: width .2s; }
#overlay-cancel { margin-top: 8px; }

/* ---------- Подвал ---------- */
.site-footer {
  background: var(--card); border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; padding: 14px 0;
}
.site-footer .container { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.site-footer button { font: inherit; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; }
.site-footer button:hover { text-decoration: underline; }

/* ---------- Инструкции ---------- */
.notice { border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; padding: 12px 16px; margin: 12px 0; }
.notice code, .code-inline { background: #eceef1; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font: 12.5px var(--mono); }
.steps { margin: 10px 0; padding-left: 22px; }
.steps li { margin: 7px 0; }

/* ---------- Адаптивность ---------- */
@media (max-width: 720px) {
  .post { flex-direction: column; gap: 8px; }
  .post-side { width: 100%; flex-direction: row; justify-content: flex-start; text-align: left; }
  .brand-text small { display: none; }
  .main-nav { width: 100%; margin-left: 0; }
  .main-nav a { flex: 1; text-align: center; }
  .dlg-msg { max-width: 100%; }
  .page-head h1 { font-size: 20px; }
  .user-head .un { font-size: 20px; }
}
