/* ===== Base / Theme tokens ===== */
:root[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg2: #0f1424;
  --card: #131a2c;
  --card2: #1a2238;
  --border: #232c47;
  --text: #e8ecf3;
  --text-mute: #8a93a8;
  --accent: #4da3ff;
  --accent-2: #6f5cff;
  --accent-soft: rgba(77,163,255,0.14);
  --danger: #ff5972;
  --success: #34d399;
  --warn: #f5a524;
}
:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg2: #eef2f9;
  --card: #ffffff;
  --card2: #f3f6fb;
  --border: #d8dee9;
  --text: #1a2238;
  --text-mute: #5a6478;
  --accent: #2563eb;
  --accent-2: #6f5cff;
  --accent-soft: rgba(37,99,235,0.10);
  --danger: #dc2626;
  --success: #059669;
  --warn: #d97706;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; margin-top: 2rem; }
h3 { font-size: 1.15rem; }
.muted { color: var(--text-mute); font-size: 0.9rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem; }
.layout-2col { display: grid; grid-template-columns: 1fr 320px; gap: 2rem; align-items: start; }
@media (max-width: 900px) { .layout-2col { grid-template-columns: 1fr; } }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.55rem 1rem; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 600; font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--card2); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-lg { padding: 0.8rem 1.4rem; font-size: 1rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; position: relative;
  text-decoration: none;
}
.icon-btn:hover { background: var(--card2); }
.theme-toggle .t-moon { display: none; }
:root[data-theme="light"] .theme-toggle .t-sun { display: none; }
:root[data-theme="light"] .theme-toggle .t-moon { display: inline; }

.link-btn { background: none; border: 0; color: var(--text-mute); cursor: pointer; font-size: 0.85rem; padding: 0; }
.link-btn:hover { color: var(--accent); text-decoration: underline; }

/* ===== Topbar ===== */
.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.6rem 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--text); font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.brand svg { color: var(--accent); }
.search-form { flex: 1; max-width: 420px; }
.search-form input {
  width: 100%; padding: 0.5rem 0.9rem;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 0.95rem;
}
.search-form input:focus { outline: none; border-color: var(--accent); }
.nav { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.nav a { color: var(--text-mute); padding: 0.4rem 0.5rem; border-radius: 8px; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--accent-soft); }
.user-chip a { display: inline-flex; align-items: center; gap: 6px; padding: 0.3rem 0.6rem; border-radius: 999px; background: var(--card); border: 1px solid var(--border); }
.user-chip .lvl { font-size: 1.05rem; }
.user-chip .rep { color: var(--accent); font-weight: 700; font-size: 0.85rem; }
.admin-link { color: var(--warn) !important; }
.badge-dot {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff; font-size: 11px;
  border-radius: 999px; padding: 1px 5px; min-width: 16px; text-align: center;
}

@media (max-width: 760px) {
  .search-form { display: none; }
  .nav .user-chip span:not(.lvl):not(.rep) { display: none; }
}

/* ===== Hero strip ===== */
.hero-strip {
  background: linear-gradient(135deg, rgba(77,163,255,0.15), rgba(111,92,255,0.15));
  border-bottom: 1px solid var(--border);
  padding: 2rem 1rem;
}
.hero-strip h1 { font-size: 2.2rem; margin: 0 0 .5rem; }
.hero-strip p { color: var(--text-mute); margin: 0; }

/* ===== Toolbar / tabs ===== */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin: 1rem 0;
}
.tabs { display: inline-flex; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.tabs a { padding: 0.4rem 0.9rem; border-radius: 8px; color: var(--text-mute); }
.tabs a:hover { background: var(--card2); text-decoration: none; }
.tabs a.active { background: var(--accent-soft); color: var(--accent); }

/* ===== Question card (list) ===== */
.q-card {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 1rem;
  padding: 1rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.7rem;
}
.q-card.small { grid-template-columns: 70px 1fr; padding: .7rem 1rem; }
.q-stats {
  display: flex; flex-direction: column; gap: 0.3rem;
  text-align: center; color: var(--text-mute); font-size: 0.78rem;
}
.q-stats div { padding: 0.2rem 0; border-radius: 6px; }
.q-stats div.accepted { background: rgba(52,211,153,0.10); color: var(--success); }
.q-stats b { display: block; color: var(--text); font-size: 1.05rem; }
.q-body h3 { margin: 0 0 0.3rem; font-size: 1.05rem; }
.q-body h4 { margin: 0; font-size: 0.95rem; }
.q-body .excerpt { color: var(--text-mute); font-size: 0.9rem; margin: 0.3rem 0 0.5rem; }
.q-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 0.85rem; }

/* ===== Tags ===== */
.tag, a.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.82rem; font-weight: 500;
  border: 1px solid transparent;
}
.tag:hover { text-decoration: none; filter: brightness(1.1); }
.tag.big { font-size: 1rem; padding: 6px 14px; }
.tag span { color: var(--text-mute); font-size: 0.75rem; }
.tags-row, .tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin: .6rem 0; }
.tag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.6rem; }
.tag-card { display: flex; flex-direction: column; padding: 0.8rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.tag-card:hover { border-color: var(--accent); text-decoration: none; }

/* ===== Sidebar cards ===== */
.sidebar { display: flex; flex-direction: column; gap: 1rem; }
.side-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.2rem;
}
.side-card h4 { margin: 0 0 0.7rem; font-size: 0.92rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-mute); }
.user-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.user-list li { display: flex; justify-content: space-between; }
.rep-mini { color: var(--accent); font-weight: 700; font-size: 0.85rem; }
.level-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.level-list .lvl { font-size: 1.1rem; }

/* ===== Auth pages ===== */
.auth-section { display: flex; align-items: center; justify-content: center; padding: 2rem 0; }
.auth-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 2rem 1.8rem;
  max-width: 440px; margin: 0 auto; width: 100%;
  box-shadow: 0 30px 80px rgba(77,163,255,0.06);
}
.auth-title {
  font-size: 1.8rem; margin: 0 0 .3rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-sub { margin: 0 0 1.4rem; color: var(--text-mute); }
.auth-form .field { display: block; margin-bottom: 0.9rem; }
.auth-form .field span { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; opacity: 0.85; }
.auth-form .field input,
.auth-form .field textarea {
  width: 100%; padding: 0.7rem 0.95rem;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 0.95rem;
}
.auth-form .field input:focus,
.auth-form .field textarea:focus { outline: none; border-color: var(--accent); }
.auth-form .check { display: flex; align-items: flex-start; gap: 8px; font-size: 0.85rem; margin: 0.8rem 0; }
.auth-alt { text-align: center; margin: 1rem 0 0; font-size: 0.95rem; }

/* ===== Forms ===== */
.form-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.5rem;
  margin: 1rem 0;
}
.form-card.danger { border-color: rgba(255,89,114,0.4); }
.form-card .field { display: block; margin-bottom: 1rem; }
.form-card .field span { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.form-card .field input,
.form-card .field textarea {
  width: 100%; padding: 0.7rem 0.95rem;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.95rem;
}
.form-card .field small { display: block; margin-top: 0.25rem; color: var(--text-mute); font-size: 0.8rem; }

/* ===== Single question / answers ===== */
.post {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.2rem 1.4rem;
  margin-bottom: 1rem;
}
.post.answer.is-accepted { border-color: var(--success); box-shadow: 0 0 0 1px rgba(52,211,153,0.2); }
.post-meta { color: var(--text-mute); font-size: 0.85rem; margin-bottom: 1rem; }
.post-body-row { display: grid; grid-template-columns: 56px 1fr; gap: 1rem; }
.vote-col { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.vote-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-mute);
  width: 40px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 1.1rem;
}
.vote-btn:hover { color: var(--accent); border-color: var(--accent); }
.vote-btn[data-active="1"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.score { font-weight: 700; font-size: 1.2rem; }
.accept-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-mute);
  width: 40px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 1.2rem;
  margin-top: 4px;
}
.accept-btn.active { background: var(--success); color: #fff; border-color: var(--success); }
.accept-mark { color: var(--success); font-size: 1.5rem; margin-top: 4px; }

.md { font-size: 1rem; word-wrap: break-word; }
.md p { margin: 0.5rem 0; }
.md pre { background: var(--bg2); padding: 0.8rem; border-radius: 8px; overflow-x: auto; border: 1px solid var(--border); }
.md code { background: var(--bg2); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
.md pre code { background: transparent; padding: 0; }
.md blockquote { border-left: 3px solid var(--accent); padding-left: 0.8rem; color: var(--text-mute); margin: 0.5rem 0; }
.md a { color: var(--accent); }
.md img { max-width: 100%; border-radius: 8px; }

.post-author {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-top: 1rem; padding-top: 0.7rem; border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.comments { margin-top: 0.8rem; padding-top: 0.7rem; border-top: 1px dashed var(--border); }
.comment { padding: 0.4rem 0; font-size: 0.88rem; color: var(--text); border-bottom: 1px dashed var(--border); }
.comment:last-child { border-bottom: 0; }
.answer-form-block textarea {
  width: 100%; min-height: 140px; padding: 0.7rem;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 0.95rem;
}

.badge-closed { background: var(--warn); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; }

/* ===== Profile ===== */
.profile-head { display: flex; gap: 1.3rem; align-items: flex-start; padding: 1rem 0 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.profile-ava { width: 80px; height: 80px; border-radius: 50%; background: var(--card2); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.progress { width: 240px; height: 8px; background: var(--card2); border-radius: 999px; overflow: hidden; margin: 0.6rem 0 0.3rem; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.7rem; }
.user-card { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: 12px; color: var(--text); }
.user-card:hover { border-color: var(--accent); text-decoration: none; }
.user-card .ava { width: 44px; height: 44px; border-radius: 50%; background: var(--card2); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.badge-item { padding: 0.5rem 0; border-bottom: 1px dashed var(--border); }
.badge-item:last-child { border-bottom: 0; }

/* ===== Notifications ===== */
.notif {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.8rem 1rem; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 0.5rem; color: var(--text);
}
.notif.unread { border-color: var(--accent); background: var(--accent-soft); }

/* ===== Flash ===== */
.flash-area { padding: 0.5rem 1rem; }
.flash {
  padding: 0.7rem 1rem; border-radius: 10px; margin-bottom: 0.5rem;
  background: var(--card); border: 1px solid var(--border);
}
.flash.error { border-color: var(--danger); color: var(--danger); }
.flash.success { border-color: var(--success); color: var(--success); }

/* ===== Empty state ===== */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-mute); background: var(--card); border-radius: 14px; border: 1px dashed var(--border); }
.empty h3 { color: var(--text); margin: 0 0 .5rem; }

/* ===== Pagination ===== */
.pagination { text-align: center; margin: 1.5rem 0; }

/* ===== Search big form ===== */
.search-form-big { display: flex; gap: 0.5rem; margin: 1rem 0; }
.search-form-big input {
  flex: 1; padding: 0.7rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 1rem;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 2rem 1rem 1rem; margin-top: 3rem; color: var(--text-mute);
  font-size: 0.9rem;
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.5rem; }
.footer-grid b { color: var(--text); display: block; margin-bottom: 0.4rem; }
.footer-grid a { display: block; padding: 2px 0; color: var(--text-mute); }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom { text-align: center; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ===== Cookie banner ===== */
#cookie-banner {
  position: fixed; bottom: 1rem; left: 1rem; right: 1rem;
  max-width: 720px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.9rem 1.2rem;
  display: flex; align-items: center; gap: 1rem; z-index: 100;
  font-size: 0.9rem; box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

/* ===== Admin ===== */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.7rem; margin: 1rem 0 1.5rem; }
.admin-stats div { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; text-align: center; }
.admin-stats b { font-size: 1.6rem; display: block; }
.admin-stats span { color: var(--text-mute); font-size: 0.85rem; }
.admin-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 0.6rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.admin-table th { background: var(--card2); color: var(--text-mute); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 0.75rem; background: var(--card2); border: 1px solid var(--border); margin-right: 4px; }
.badge.ban { background: var(--danger); color: #fff; border-color: transparent; }
.badge.admin { background: var(--warn); color: #fff; border-color: transparent; }

/* ===== Legal pages ===== */
.legal h2 { margin-top: 1.5rem; }
.legal ul, .legal ol { padding-left: 1.3rem; }
.legal li { margin: 0.3rem 0; }

/* ===== Ad slots ===== */
.ad-slot {
  background: var(--card2);
  border: 1px dashed var(--border);
  border-radius: 10px; padding: 0.5rem;
  text-align: center; min-height: 60px;
  margin: 1rem 0;
}
.ad-slot:empty::before { content: "реклама"; color: var(--text-mute); font-size: 0.8rem; }
