:root {
  --bg:      #0b0b0f;
  --bg2:     #101017;
  --bg3:     #16161f;
  --surface: #13131a;
  --surface2:#1c1c27;
  --border:  #2a2a3a;
  --accent:  #7b68ee;
  --accent2: #6a59d9;
  --text:    #e0e0f0;
  --text2:   #9090a8;
  --danger:  #e05555;
  --success: #4caf88;
  --pin:     #f0b840;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.6; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Nav ──────────────────────────────────────────────────────────── */
.f-nav {
  position: sticky; top: 0; z-index: 200;
  background: rgba(11,11,15,.96); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.f-nav-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 20px;
  height: 54px; display: flex; align-items: center; gap: 14px;
}
.f-nav-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.f-nav-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; color: var(--text);
  transition: color .15s;
}
.f-nav-logo:hover { color: var(--accent); }
.f-nav-sep { color: var(--border); font-size: 18px; }
.f-nav-forum { color: var(--accent); font-weight: 600; font-size: 15px; }
.f-nav-center { flex: 1; }
.f-nav-right { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }

.f-search {
  display: flex; align-items: center;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; max-width: 380px;
}
.f-search-input {
  background: none; border: none; outline: none;
  padding: 8px 12px; color: var(--text); font-size: 14px; width: 100%;
}
.f-search-input::placeholder { color: var(--text2); }
.f-search-btn {
  background: none; border: none; padding: 0 12px; cursor: pointer;
  color: var(--text2); display: flex; align-items: center; height: 100%;
  transition: color .15s;
}
.f-search-btn:hover { color: var(--text); }

.f-nav-auth, .f-nav-user { display: flex; align-items: center; gap: 8px; }
.f-nav-username { color: var(--accent); font-weight: 500; font-size: 14px; }
.f-nav-username:hover { text-decoration: underline; cursor: pointer; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.f-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 8px; border: none;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none; white-space: nowrap;
}
.f-btn-accent { background: var(--accent); color: #fff; }
.f-btn-accent:hover { background: var(--accent2); }
.f-btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.f-btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,.2); }
.f-btn-sm { padding: 5px 12px; font-size: 13px; }
.f-btn-full { width: 100%; justify-content: center; }
.f-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Layout ───────────────────────────────────────────────────────── */
.f-wrap { max-width: 1000px; margin: 0 auto; padding: 28px 20px; }
.f-wrap-narrow { max-width: 680px; }
.f-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 12px;
}
.f-spinner {
  text-align: center; padding: 80px 20px;
  color: var(--text2); font-size: 14px;
}
.f-spinner::after { content: '...'; }
.f-empty { text-align: center; padding: 48px 20px; color: var(--text2); font-size: 14px; }
.f-error { text-align: center; padding: 48px 20px; color: var(--danger); }
.f-error a { color: var(--accent); }
.f-muted { color: var(--text2); }

/* ── Breadcrumb ───────────────────────────────────────────────────── */
.f-breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px; font-size: 14px; color: var(--text2);
}
.f-breadcrumb a { color: var(--accent); }
.f-breadcrumb a:hover { text-decoration: underline; }
.f-breadcrumb-title {
  color: var(--text); font-weight: 500;
  max-width: 350px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Section heads ────────────────────────────────────────────────── */
.f-section-head {
  font-size: 12px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 12px;
}
.f-section-head-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}

/* ── Recent threads (home) ────────────────────────────────────────── */
.f-recent { margin-bottom: 36px; }
.f-recent-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.f-recent-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  transition: background .15s; gap: 16px;
}
.f-recent-row:last-child { border-bottom: none; }
.f-recent-row:hover { background: var(--surface2); }
.f-recent-title {
  font-size: 14px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.f-recent-row:hover .f-recent-title { color: var(--accent); }
.f-recent-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; flex-shrink: 0;
}

/* ── Categories (home) ────────────────────────────────────────────── */
.f-cats-list { display: flex; flex-direction: column; gap: 6px; }
.f-cat-card {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; transition: border-color .15s, background .15s;
}
.f-cat-card:hover { border-color: var(--accent); background: var(--surface2); }
.f-cat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: rgba(123,104,238,.12);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); flex-shrink: 0;
}
.f-cat-body { flex: 1; min-width: 0; }
.f-cat-name { font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 2px; }
.f-cat-card:hover .f-cat-name { color: var(--accent); }
.f-cat-desc { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-cat-arrow { color: var(--border); font-size: 18px; flex-shrink: 0; }
.f-cat-card:hover .f-cat-arrow { color: var(--accent); }

/* ── Thread list ──────────────────────────────────────────────────── */
.f-thread-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 20px;
}
.f-thread-list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em;
}
.f-thread-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  transition: background .15s; gap: 16px;
}
.f-thread-row:last-child { border-bottom: none; }
.f-thread-row:hover { background: var(--surface2); }
.f-thread-pinned { background: rgba(123,104,238,.04); }
.f-thread-main { flex: 1; min-width: 0; }
.f-thread-title-row {
  font-size: 14px; font-weight: 500; color: var(--text);
  margin-bottom: 4px; display: flex; align-items: center; gap: 6px;
  overflow: hidden;
}
.f-thread-row:hover .f-thread-title-row { color: var(--accent); }
.f-thread-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-thread-sub { font-size: 13px; color: var(--text2); }
.f-thread-stats { display: flex; align-items: center; gap: 24px; flex-shrink: 0; text-align: center; }
.f-stat-block { min-width: 48px; }
.f-stat-val { font-size: 15px; font-weight: 600; display: block; }
.f-stat-label { font-size: 11px; color: var(--text2); }
.f-stat-time { font-size: 13px; color: var(--text2); min-width: 80px; text-align: right; }

/* ── Thread page ──────────────────────────────────────────────────── */
.f-thread-header { margin-bottom: 24px; }
.f-thread-title-big { font-size: 22px; font-weight: 700; line-height: 1.3; margin-bottom: 8px; }
.f-thread-header-meta { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text2); flex-wrap: wrap; }

/* ── Posts ────────────────────────────────────────────────────────── */
.f-posts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.f-post {
  display: flex; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.f-post-sidebar {
  width: 116px; flex-shrink: 0; padding: 18px 10px;
  background: var(--surface2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.f-post-author { font-size: 13px; font-weight: 600; text-align: center; word-break: break-word; }
.f-post-role { font-size: 11px; color: var(--accent); font-weight: 600; }
.f-post-body { flex: 1; min-width: 0; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.f-post-meta {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text2); padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.f-post-num { margin-left: auto; }
.f-edited { font-style: italic; }

/* Post content (rendered Markdown) */
.f-post-content { font-size: 15px; line-height: 1.75; color: var(--text); }
.f-post-content p { margin-bottom: 10px; }
.f-post-content p:last-child { margin-bottom: 0; }
.f-post-content h1,.f-post-content h2,.f-post-content h3,
.f-post-content h4 { margin: 16px 0 8px; font-weight: 700; }
.f-post-content h1 { font-size: 20px; }
.f-post-content h2 { font-size: 17px; }
.f-post-content h3 { font-size: 15px; }
.f-post-content code {
  background: var(--bg3); padding: 2px 6px; border-radius: 5px;
  font-size: 13px; font-family: 'Consolas', 'Fira Code', monospace;
}
.f-post-content pre {
  background: var(--bg3); padding: 14px 16px;
  border-radius: 8px; overflow-x: auto; margin: 12px 0;
  border: 1px solid var(--border);
}
.f-post-content pre code { background: none; padding: 0; }
.f-post-content blockquote {
  border-left: 3px solid var(--accent); padding-left: 14px;
  color: var(--text2); margin: 12px 0; font-style: italic;
}
.f-post-content a { color: var(--accent); }
.f-post-content a:hover { text-decoration: underline; }
.f-post-content ul,.f-post-content ol { padding-left: 22px; margin-bottom: 10px; }
.f-post-content li { margin-bottom: 4px; }
.f-post-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.f-post-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.f-post-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.f-post-content th,.f-post-content td { padding: 8px 12px; border: 1px solid var(--border); }
.f-post-content th { background: var(--surface2); font-weight: 600; }

/* Reactions */
.f-post-reactions { display: flex; gap: 6px; flex-wrap: wrap; }
.f-reaction {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px; font-size: 14px;
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; gap: 4px;
}
.f-reaction:hover,.f-reaction.active { border-color: var(--accent); background: rgba(123,104,238,.18); }
.f-reaction-cnt { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ── Reply / New thread forms ─────────────────────────────────────── */
.f-reply-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-top: 8px;
}
.f-reply-actions { display: flex; justify-content: flex-end; margin-top: 12px; gap: 8px; }
.f-reply-hint {
  text-align: center; padding: 20px; color: var(--text2); font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  margin-top: 8px;
}
.f-reply-hint a { color: var(--accent); cursor: pointer; }

.f-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.f-field label { font-size: 13px; font-weight: 500; color: var(--text2); }
.f-input,.f-select,.f-textarea {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; color: var(--text);
  font-size: 14px; width: 100%; transition: border-color .15s;
  font-family: inherit;
}
.f-input:focus,.f-select:focus,.f-textarea:focus { outline: none; border-color: var(--accent); }
.f-textarea { resize: vertical; line-height: 1.6; }
.f-select { cursor: pointer; appearance: none; }
.f-select option { background: var(--surface); }
.f-form-actions { display: flex; gap: 10px; margin-top: 8px; }
.f-field-error { color: var(--danger); font-size: 13px; }

/* ── Auth modal ───────────────────────────────────────────────────── */
.f-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  z-index: 1000; display: flex; align-items: center;
  justify-content: center; padding: 20px;
}
.f-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; width: 100%; max-width: 400px;
  position: relative; animation: f-modal-in .18s ease;
}
@keyframes f-modal-in { from { opacity:0; transform: scale(.96); } }
.f-modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: var(--text2);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  line-height: 1;
}
.f-modal-close:hover { color: var(--text); background: var(--surface2); }
.f-modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.f-auth-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--surface2); border-radius: 8px; padding: 4px;
}
.f-auth-tab {
  flex: 1; padding: 8px; border: none; background: none;
  color: var(--text2); font-size: 14px; font-weight: 500;
  cursor: pointer; border-radius: 6px; transition: all .15s;
}
.f-auth-tab.active { background: var(--accent); color: #fff; }
.f-auth-form.hidden { display: none; }
.f-auth-err { color: var(--danger); font-size: 13px; margin-bottom: 12px; display: none; }

/* ── Badges ───────────────────────────────────────────────────────── */
.f-badge { font-size: 14px; }
.f-tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
}
.f-tag-mod { background: rgba(123,104,238,.2); color: var(--accent); }
.f-tag-admin { background: rgba(224,85,85,.2); color: var(--danger); }
.f-tag-closed { background: rgba(144,144,168,.15); color: var(--text2); }

/* ── Pagination ───────────────────────────────────────────────────── */
.f-pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 20px 0; }
.f-page {
  display: flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 6px;
  border-radius: 8px; font-size: 14px;
  border: 1px solid var(--border); color: var(--text2);
  transition: all .15s;
}
.f-page:hover { border-color: var(--accent); color: var(--accent); }
.f-page.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.f-page-dots { border-color: transparent; cursor: default; pointer-events: none; }

/* ── Avatar ───────────────────────────────────────────────────────── */
.f-avatar {
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 700;
  flex-shrink: 0; user-select: none;
}

/* ── Search results ───────────────────────────────────────────────── */
.f-search-results { display: flex; flex-direction: column; gap: 8px; }
.f-search-section { margin-bottom: 24px; }
.f-search-hit {
  display: block; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; transition: border-color .15s;
}
.f-search-hit:hover { border-color: var(--accent); }
.f-search-hit-title { font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.f-search-hit-body { font-size: 13px; color: var(--text2); margin-bottom: 4px; }

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .f-nav-center { display: none; }
  .f-post-sidebar { width: 76px; }
  .f-thread-stats { gap: 14px; }
  .f-stat-time { display: none; }
  .f-thread-title-big { font-size: 18px; }
  .f-breadcrumb-title { max-width: 160px; }
  .f-cat-desc { display: none; }
}
@media (max-width: 480px) {
  .f-wrap { padding: 16px 14px; }
  .f-post-body { padding: 12px 14px; }
  .f-post-sidebar { display: none; }
}
