/* ===== Topicly design system ===== */
:root {
  --bg: #0a0912;
  --bg-elevated: #14121f;
  --bg-card: rgba(23,21,36,0.7);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --purple: #8b5cf6;
  --purple-light: #c4b5fd;
  --purple-dark: #6d28d9;
  --gradient: linear-gradient(135deg, #a78bfa, #7c3aed);
  --text: #f3f1fb;
  --text-dim: #a9a3c2;
  --text-faint: #736d92;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fbbf24;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-glow: 0 8px 30px rgba(124,58,237,0.25);
  --shadow-card: 0 2px 20px rgba(0,0,0,0.35);
  --transition: 0.18s cubic-bezier(.4,0,.2,1);
  --up-color: #22c55e;
  --down-color: #f87171;
}

/* ===== Light Mode ===== */
html.light {
  --bg: #f5f5fa;
  --bg-elevated: #ffffff;
  --bg-card: rgba(255,255,255,0.9);
  --border: rgba(0,0,0,0.09);
  --border-strong: rgba(0,0,0,0.15);
  --text: #1a1535;
  --text-dim: #4a4568;
  --text-faint: #8a85a8;
  --shadow-card: 0 2px 20px rgba(0,0,0,0.08);
  --shadow-glow: 0 8px 30px rgba(124,58,237,0.2);
}

/* ===== Logo switching – dark / light mode ===== */
/* !important is required because .brand-logo { display:block } is declared
   later in the file and would otherwise win by source order at equal specificity */
.logo-dark  { display: block !important; }
.logo-light { display: none  !important; }
html.light .logo-dark  { display: none  !important; }
html.light .logo-light { display: block !important; }

/* Mascot images now have transparent backgrounds (PNG) – no blend-mode needed */

html.light body {
  background: radial-gradient(circle at 20% 0%, #ede8ff 0%, #f5f5fa 45%), var(--bg);
}

html.light .topbar {
  background: rgba(245,245,250,0.88);
}

html.light .search-box {
  background: #eeecfa;
}

html.light .ai-panel {
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(0,0,0,0.15);
}

html.light .ai-msg.bot {
  background: #f0eeff;
  border-color: rgba(139,92,246,0.2);
}

html.light .card {
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
}

html.light .form-card {
  background: rgba(255,255,255,0.95);
}

html.light .form-control {
  background: #f9f9ff;
  color: var(--text);
}

html.light .sidebar-link:hover, html.light .sidebar-link.active {
  background: rgba(139,92,246,0.1);
}

html.light .admin-stat-card {
  background: #ffffff;
}

html.light .admin-table th {
  background: rgba(139,92,246,0.05);
}

html.light .admin-table tr:hover td {
  background: rgba(139,92,246,0.03);
}

html.light .vote-btn {
  color: var(--text-faint);
}

html.light .vote-btn:hover {
  background: rgba(139,92,246,0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: radial-gradient(circle at 20% 0%, #1b1530 0%, #0a0912 45%), var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", "Tahoma", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

::selection { background: var(--purple); color: white; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(10,9,18,0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
}
.brand { flex-shrink: 0; display: flex; align-items: center; }
.brand-logo { height: 30px; display: block; }

.search-box {
  flex: 1; max-width: 420px;
  display: flex; align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 6px 6px 14px;
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139,92,246,.12); }
.search-box input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; padding: 4px 0;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box button {
  background: var(--gradient); border: none; color: white;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: opacity var(--transition);
}
.search-box button:hover { opacity: .85; }

.nav-actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }

/* Theme toggle */
.theme-toggle-btn {
  transition: transform 0.3s ease, color var(--transition);
}
.theme-toggle-btn:hover { transform: rotate(20deg) scale(1.1); }

/* ===== Buttons ===== */
.btn {
  border: none; border-radius: 999px; padding: 9px 18px;
  font-size: 14px; font-weight: 600; transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:active { transform: scale(0.95); }
.btn-primary { background: var(--gradient); color: white; box-shadow: var(--shadow-glow); }
.btn-primary:hover { opacity: .9; box-shadow: 0 10px 36px rgba(124,58,237,.38); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255,255,255,.04); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: rgba(248,113,113,.12); color: var(--danger); border: 1px solid rgba(248,113,113,.2); }
.btn-danger:hover { background: rgba(248,113,113,.18); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); position: relative;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255,255,255,.06); }
.badge-dot {
  position: absolute; top: -3px; left: -3px;
  background: var(--purple); color: white; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
  border: 2px solid var(--bg);
}

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--gradient); color: white; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; overflow: hidden; flex-shrink: 0; border: 2px solid transparent;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 84px; height: 84px; font-size: 30px; border: 3px solid var(--bg); }

/* ===== App shell / layout ===== */
.app-shell { max-width: 1180px; margin: 0 auto; padding: 24px 20px 100px; min-height: 70vh; }

.layout-with-sidebar { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .layout-with-sidebar { grid-template-columns: 1fr; } .sidebar { display: none !important; } }

.sidebar { position: sticky; top: 82px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sidebar-link svg { opacity: .7; flex-shrink: 0; }
.sidebar-link:hover { background: var(--bg-elevated); color: var(--text); }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active { background: rgba(139,92,246,.14); color: var(--purple-light); }
.sidebar-link.active svg { opacity: 1; color: var(--purple-light); }
.sidebar-title { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); padding: 16px 14px 5px; font-weight: 700; }

/* ===== Cards / feed ===== */
.feed-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.chip {
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--bg-elevated); color: var(--text-dim); border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip.active { background: var(--gradient); color: white; border-color: transparent; box-shadow: var(--shadow-glow); }
.chip:hover:not(.active) { color: var(--text); border-color: var(--border-strong); }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.018));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition), background 0.3s ease;
  box-shadow: var(--shadow-card);
}
.card:hover { border-color: var(--border-strong); }

/* ===== Vote column ===== */
.post-card { display: flex; gap: 14px; cursor: pointer; }
.vote-col {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding-top: 2px; min-width: 46px;
}

/* Up vote – always greenish */
.vote-btn {
  background: none; border: none;
  width: 38px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  transition: background var(--transition), color var(--transition), transform var(--transition);
  font-size: 13px; font-weight: 700; gap: 4px;
}
.vote-btn.vote-up { color: var(--text-faint); }
.vote-btn.vote-up:hover { background: rgba(34,197,94,.12); color: var(--up-color); transform: scale(1.12); }
.vote-btn.vote-up.active-up { color: var(--up-color); background: rgba(34,197,94,.14); }
.vote-btn.vote-up.active-up:hover { background: rgba(34,197,94,.22); }

.vote-btn.vote-down { color: var(--text-faint); }
.vote-btn.vote-down:hover { background: rgba(248,113,113,.12); color: var(--down-color); transform: scale(1.12); }
.vote-btn.vote-down.active-down { color: var(--down-color); background: rgba(248,113,113,.12); }
.vote-btn.vote-down.active-down:hover { background: rgba(248,113,113,.2); }

.vote-btn:active { transform: scale(0.9); }
.vote-score { font-weight: 800; font-size: 14px; color: var(--text); min-width: 18px; text-align: center; }

.post-main { flex: 1; min-width: 0; }
.post-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-faint); margin-bottom: 6px; flex-wrap: wrap; }
.post-author-avatar { display: inline-flex; align-items: center; flex-shrink: 0; border-radius: 50%; transition: opacity 0.15s; }
.post-author-avatar:hover { opacity: .8; }
.post-author-link { color: var(--text-dim); font-weight: 600; transition: color 0.15s; }
.post-author-link:hover { color: var(--purple-l); }
.post-detail-author-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-detail-author-row .post-author-link { font-size: 14px; color: var(--text); font-weight: 700; }
.post-detail-author-row .post-author-link:hover { color: var(--purple-l); }
.post-type-badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: rgba(139,92,246,.16); color: var(--purple-light); text-transform: uppercase; letter-spacing: .04em;
}
.post-type-badge.poll-badge { background: rgba(251,191,36,.12); color: var(--warning); }
.verified-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  background: var(--gradient); color: white; border-radius: 50%; font-size: 9px; font-weight: 900;
}
.post-title { font-size: 17px; font-weight: 700; margin: 0 0 6px; color: var(--text); line-height: 1.45; }
.post-body-preview { color: var(--text-dim); font-size: 14px; margin: 0 0 10px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-wrap; }
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag-chip { font-size: 12px; color: var(--purple-light); background: rgba(139,92,246,.1); padding: 3px 10px; border-radius: 999px; transition: background var(--transition); }
.tag-chip:hover { background: rgba(139,92,246,.18); }
.post-footer-stats {
  display: flex; gap: 16px; font-size: 13px; color: var(--text-faint); align-items: center; margin-top: 8px;
}
.post-footer-stats span { display: flex; align-items: center; gap: 5px; }
.post-footer-stats svg { opacity: .6; }
.best-answer-flag { color: var(--success); font-weight: 700; display: flex; align-items: center; gap: 4px; }

/* ===== Post card images – big and prominent ===== */
.post-images-preview {
  display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.post-images-preview img {
  height: 200px;
  max-width: 100%;
  border-radius: var(--radius-sm);
  object-fit: cover;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: zoom-in;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.post-images-preview img:hover { transform: scale(1.02); box-shadow: 0 8px 28px rgba(0,0,0,0.35); }

/* Single image gets full width */
.post-images-preview.single-img img {
  height: 280px;
  width: 100%;
  object-fit: cover;
}

/* ===== Empty / loading ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-state img { width: 110px; margin-bottom: 16px; opacity: .85; filter: drop-shadow(0 4px 16px rgba(139,92,246,.2)); }
.empty-state h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; }
.loading-spinner { display: flex; justify-content: center; padding: 50px 0; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--purple);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Forms ===== */
.form-page { max-width: 580px; margin: 20px auto; }
.form-card {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 30px;
  box-shadow: var(--shadow-card);
}
.form-card h2 { margin-top: 0; font-size: 22px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.form-control {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: 14px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139,92,246,.12); }
textarea.form-control { min-height: 130px; resize: vertical; font-family: inherit; line-height: 1.6; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.form-error { background: rgba(248,113,113,.1); color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; border: 1px solid rgba(248,113,113,.2); }
.form-actions { display: flex; gap: 10px; margin-top: 22px; align-items: center; flex-wrap: wrap; }
.form-switch-link { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--text-dim); }
.tag-input-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-input-list .tag-chip { display: flex; align-items: center; gap: 6px; }
.tag-remove { cursor: pointer; font-weight: 900; line-height: 1; }
.poll-option-row { display: flex; gap: 8px; margin-bottom: 8px; }
.ai-inline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ai-suggest-box { background: rgba(139,92,246,.08); border: 1px solid rgba(139,92,246,.25); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 12px; font-size: 13.5px; white-space: pre-wrap; }

/* ===== Create form – post type toggle ===== */
.create-mode-toggle {
  display: flex; gap: 10px; margin-bottom: 6px;
}
.mode-btn {
  flex: 1; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--bg);
  color: var(--text-dim); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  cursor: pointer;
}
.mode-btn:hover { border-color: var(--purple); color: var(--text); }
.mode-btn.active { border-color: var(--purple); background: rgba(139,92,246,.12); color: var(--purple-light); }
.mode-btn.active svg { color: var(--purple-light); }

/* ===== Image upload zone ===== */
.image-upload-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 22px 16px; text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative; overflow: hidden;
}
.image-upload-zone:hover, .image-upload-zone.drag-over {
  border-color: var(--purple); background: rgba(139,92,246,.06);
}
.image-upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.image-upload-zone-label {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; color: var(--text-faint);
}
.image-upload-zone-label svg { color: var(--purple-light); opacity: .8; }
.image-upload-zone-label span { font-size: 13.5px; }
.image-upload-zone-label small { font-size: 11.5px; color: var(--text-faint); }
.image-preview-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.image-preview-item { position: relative; }
.image-preview-item img { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.image-preview-remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  background: var(--danger); border: none; border-radius: 50%; color: white;
  font-size: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-weight: 900; line-height: 1;
}

/* ===== Post detail ===== */
.post-detail-header { display: flex; gap: 16px; }
.post-detail-title { font-size: 24px; font-weight: 800; margin: 0 0 10px; line-height: 1.4; }
.post-detail-body { color: var(--text-dim); white-space: pre-wrap; font-size: 15px; margin-bottom: 14px; line-height: 1.7; }

/* Post detail images – full-width & big */
.post-detail-images { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.post-detail-images img {
  width: 100%;
  max-height: 500px;
  border-radius: var(--radius);
  object-fit: cover;
  cursor: zoom-in;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
.post-detail-images img:hover { transform: scale(1.01); box-shadow: 0 12px 36px rgba(0,0,0,0.4); }

/* Multiple images side by side if ≥2 */
.post-detail-images.multi-img {
  flex-direction: row; flex-wrap: wrap;
}
.post-detail-images.multi-img img {
  flex: 1; min-width: 240px; max-height: 320px;
}

.post-actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

.ai-answer-box { background: linear-gradient(135deg, rgba(139,92,246,.12), rgba(139,92,246,.03)); border: 1px solid rgba(139,92,246,.25); border-radius: var(--radius); padding: 16px 18px; margin: 20px 0; }
.ai-answer-box .ai-tag { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--purple-light); margin-bottom: 8px; font-size: 13.5px; }
.ai-answer-box img { width: 24px; height: 24px; border-radius: 50%; }
.ai-answer-text { white-space: pre-wrap; font-size: 14.5px; color: var(--text); line-height: 1.7; }

/* ===== Comments ===== */
.comments-section { margin-top: 26px; }
.comments-section h3 { font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.comment-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-body { flex: 1; }
.comment-meta { font-size: 12.5px; color: var(--text-faint); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-text { font-size: 14.5px; color: var(--text); white-space: pre-wrap; margin-bottom: 8px; line-height: 1.6; }
.comment-actions { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-faint); }
.comment-actions button { background: none; border: none; color: inherit; padding: 4px 8px; border-radius: 8px; display: flex; align-items: center; gap: 5px; transition: background var(--transition), color var(--transition); }
.comment-actions button:hover { color: var(--text); background: var(--bg-elevated); }
.comment-actions .vote-up-btn { color: var(--text-faint); }
.comment-actions .vote-up-btn:hover { color: var(--up-color); background: rgba(34,197,94,.1); }
.comment-actions .vote-up-btn.active { color: var(--up-color); background: rgba(34,197,94,.12); }
.comment-actions .vote-down-btn { color: var(--text-faint); }
.comment-actions .vote-down-btn:hover { color: var(--down-color); background: rgba(248,113,113,.1); }
.comment-actions .vote-down-btn.active { color: var(--down-color); background: rgba(248,113,113,.1); }
.best-answer-item { border: 1px solid rgba(74,222,128,.35); background: rgba(74,222,128,.04); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.nested-reply { margin-inline-start: 44px; margin-top: 8px; }
.reply-form { display: flex; gap: 8px; margin-top: 10px; }
.reply-form input { flex: 1; }
.comment-input-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 20px; }
.comment-input-row .avatar { margin-top: 2px; }
.comment-input-wrap { flex: 1; }
.comment-input-wrap textarea { min-height: 80px; }
.ai-comment-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(139,92,246,.14); color: var(--purple-light);
}
.ai-comment-badge img { width: 14px; height: 14px; border-radius: 50%; }

/* ===== Communities ===== */
.communities-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.community-card { display: flex; flex-direction: column; gap: 8px; }
.community-card-top { display: flex; align-items: center; gap: 10px; }
.community-name { font-weight: 700; font-size: 15px; }
.community-desc { color: var(--text-dim); font-size: 13.5px; min-height: 38px; }
.community-meta-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }

/* ===== Profile ===== */
.profile-cover { height: 150px; border-radius: var(--radius); background: var(--gradient); position: relative; margin-bottom: 54px; overflow: hidden; }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-wrap { position: absolute; bottom: -40px; right: 24px; }
.profile-head-info { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.profile-name-row { display: flex; align-items: center; gap: 8px; }
.profile-username { color: var(--text-faint); font-size: 14px; }
.profile-bio { color: var(--text-dim); margin: 10px 0; max-width: 560px; line-height: 1.7; }
.profile-stats { display: flex; gap: 22px; margin: 10px 0 18px; font-size: 14px; }
.profile-stats b { color: var(--text); }
.profile-stats span { color: var(--text-faint); }
.profile-skills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ===== Poll ===== */
.poll-box { margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.poll-option {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; cursor: pointer; overflow: hidden; font-size: 14px;
  transition: border-color var(--transition);
}
.poll-option:hover { border-color: var(--border-strong); }
.poll-option-fill { position: absolute; inset: 0; background: rgba(139,92,246,.16); z-index: 0; transition: width .5s cubic-bezier(.4,0,.2,1); border-radius: var(--radius-sm); }
.poll-option-label { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.poll-meta { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; }

/* ===== Notifications ===== */
.notif-item {
  display: flex; gap: 12px; padding: 13px 10px; border-radius: var(--radius-sm);
  transition: background var(--transition); align-items: flex-start; cursor: pointer;
}
.notif-item.unread { background: rgba(139,92,246,.07); }
.notif-item:hover { background: var(--bg-elevated); }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(139,92,246,.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { color: var(--purple-light); }
.notif-icon.up-icon { background: rgba(34,197,94,.15); }
.notif-icon.up-icon svg { color: var(--up-color); }
.notif-icon.down-icon { background: rgba(248,113,113,.1); }
.notif-icon.down-icon svg { color: var(--danger); }
.notif-icon.reply-icon { background: rgba(74,222,128,.1); }
.notif-icon.reply-icon svg { color: var(--success); }
.notif-text { font-size: 14px; line-height: 1.5; }
.notif-time { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ===== AI floating widget ===== */
.ai-fab {
  position: fixed; bottom: 24px; left: 24px; z-index: 60;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--gradient); border: none;
  display: flex; align-items: center; justify-content: center;
  animation: float 3.5s ease-in-out infinite;
  box-shadow: 0 6px 24px rgba(124,58,237,.55);
  transition: box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
  padding: 0;
}
.ai-fab:hover { box-shadow: 0 10px 36px rgba(124,58,237,.75); transform: scale(1.08); }
.ai-fab img { width: 86%; height: 86%; object-fit: contain; display: block; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.ai-panel {
  position: fixed; bottom: 100px; left: 24px; z-index: 61;
  width: 360px; max-width: calc(100vw - 32px); height: 490px; max-height: 72vh;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
  transition: opacity .2s, transform .2s, background 0.3s ease;
}
.ai-panel.hidden { opacity: 0; pointer-events: none; transform: translateY(14px) scale(.97); }
.ai-panel-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: rgba(139,92,246,.08); }
.ai-panel-header img { width: 34px; height: 34px; border-radius: 50%; }
.ai-panel-title { flex: 1; display: flex; flex-direction: column; }
.ai-panel-title span { font-size: 12px; color: var(--text-faint); }
#ai-close { background: none; border: none; color: var(--text-faint); display: flex; align-items: center; justify-content: center; border-radius: 6px; padding: 4px; transition: color var(--transition), background var(--transition); }
#ai-close:hover { color: var(--text); background: rgba(255,255,255,.08); }
.ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; white-space: pre-wrap; line-height: 1.6; }
.ai-msg.user { align-self: flex-end; background: var(--gradient); color: white; border-bottom-left-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-bottom-right-radius: 4px; }
.ai-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.ai-form input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 9px 14px; color: var(--text); outline: none; transition: border-color var(--transition); font-size: 13.5px; }
.ai-form input:focus { border-color: var(--purple); }
.ai-form button { background: var(--gradient); color: white; border: none; padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 13.5px; }

/* ===== Toasts ===== */
.toast-container { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text); padding: 11px 20px; border-radius: 999px; font-size: 13.5px;
  box-shadow: 0 12px 36px rgba(0,0,0,.45); animation: toast-in .25s cubic-bezier(.4,0,.2,1);
  display: flex; align-items: center; gap: 8px;
}
.toast.error { border-color: rgba(248,113,113,.5); color: #fecaca; }
.toast.success { border-color: rgba(74,222,128,.5); color: #bbf7d0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ===== Modal ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(3px); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 26px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal-box img { width: 90px; margin-bottom: 10px; }
.modal-box h3 { margin: 6px 0; }
.modal-box p { color: var(--text-dim); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* ===== Footer ===== */
.site-footer { text-align: center; padding: 26px 20px 100px; color: var(--text-faint); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.site-footer .slogan { color: var(--purple-light); font-weight: 600; }

/* ===== Misc ===== */
.section-title { font-size: 18px; font-weight: 800; margin: 26px 0 14px; }
.section-title:first-child { margin-top: 0; }
.pill-list { display: flex; gap: 8px; flex-wrap: wrap; }
.link-purple { color: var(--purple-light); font-weight: 600; }
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.hidden { display: none !important; }

/* ===== @topicly Mention autocomplete ===== */
.mention-wrap { position: relative; }
.mention-dropdown {
  position: absolute; bottom: calc(100% + 6px); right: 0; left: 0; z-index: 30;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: 0 12px 36px rgba(0,0,0,.45);
  overflow: hidden;
}
.mention-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  cursor: pointer; font-size: 13.5px; transition: background var(--transition);
}
.mention-item:hover { background: rgba(139,92,246,.1); }
.mention-item img { width: 26px; height: 26px; border-radius: 50%; }
.mention-item span:nth-child(2) { flex: 1; font-weight: 600; color: var(--text); }
.mention-paper-icon { width: 26px; height: 26px; display:flex; align-items:center; justify-content:center; color: var(--purple-light); }
.tool-icon-wrap { font-size: 0; display:flex; align-items:center; justify-content:center; width:40px; height:40px; background:rgba(139,92,246,.15); border-radius:10px; color:var(--purple-light); flex-shrink:0; }
.tool-icon-wrap svg { width: 22px; height: 22px; }

/* ===== Paper image in comments ===== */
.comment-paper-img {
  max-width: 100%; width: 160px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card); margin-top: 6px; display: block;
  cursor: zoom-in; transition: transform var(--transition);
}
.comment-paper-img:hover { transform: scale(1.04); }

/* ===== Tools page ===== */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.tool-card { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.tool-card-header { display: flex; align-items: flex-start; gap: 14px; }
.tool-icon-wrap { font-size: 32px; line-height:1; flex-shrink:0; }
.tool-title { font-size: 17px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.tool-desc { font-size: 13px; margin: 0; }
.tool-body { display: flex; flex-direction: column; gap: 10px; }
.paper-result { margin-top: 4px; }
.paper-output-img {
  max-width: 100%; width: 100%; border-radius: var(--radius);
  box-shadow: var(--shadow-card); display: block;
}
@media (max-width: 860px) { .tools-grid { grid-template-columns: 1fr; } }

/* ===== Admin Panel ===== */
.admin-panel { max-width: 1100px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.admin-header h2 { margin: 0; display: flex; align-items: center; gap: 10px; }

.admin-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 26px;
}
.admin-stat-card {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.018));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition), transform var(--transition);
}
.admin-stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.admin-stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.admin-stat-icon svg { width: 20px; height: 20px; color: var(--purple-light); }
.admin-stat-num { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; }
.admin-stat-label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.admin-stat-sub { font-size: 11.5px; color: var(--success); margin-top: 2px; }

.admin-tab-bar { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.admin-tab {
  padding: 10px 18px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 7px; margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--purple-light); border-bottom-color: var(--purple); }

.admin-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
.admin-table th {
  background: rgba(255,255,255,.03); padding: 12px 14px;
  text-align: right; font-size: 12px; font-weight: 700; color: var(--text-dim);
  letter-spacing: .03em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
  color: var(--text);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,.02); }
.admin-row-banned td { opacity: .55; }

.admin-role-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.admin-status-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.admin-status-badge.active  { background: rgba(74,222,128,.12); color: var(--success); }
.admin-status-badge.banned  { background: rgba(248,113,113,.12); color: var(--danger); }

.admin-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.admin-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.admin-btn:hover { transform: scale(1.1); }
.admin-btn:active { transform: scale(.92); }
.admin-btn svg { width: 13px; height: 13px; }
.admin-btn.danger { background: rgba(248,113,113,.15); color: var(--danger); }
.admin-btn.danger:hover { background: rgba(248,113,113,.28); }
.admin-btn.warn   { background: rgba(251,191,36,.12);  color: var(--warning); }
.admin-btn.warn:hover   { background: rgba(251,191,36,.22); }
.admin-btn.green  { background: rgba(74,222,128,.12);  color: var(--success); }
.admin-btn.green:hover  { background: rgba(74,222,128,.22); }
.admin-btn.purple { background: rgba(139,92,246,.15);  color: var(--purple-light); }
.admin-btn.purple:hover { background: rgba(139,92,246,.28); }

/* ===== Hamburger button ===== */
.hamburger-btn {
  display: none;
  flex-direction: column; justify-content: center; align-items: center;
  gap: 5px; width: 40px; height: 40px; border-radius: 10px;
  background: none; border: none; cursor: pointer; color: var(--text);
  flex-shrink: 0; padding: 8px;
  transition: background var(--transition);
}
.hamburger-btn:hover { background: rgba(255,255,255,.06); }
.hamburger-btn span {
  display: block; width: 20px; height: 2px; border-radius: 2px;
  background: currentColor; transition: transform 0.22s ease, opacity 0.22s ease;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== Mobile nav drawer ===== */
.mobile-nav-backdrop {
  display: none; position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  animation: fade-in .2s ease;
}
.mobile-nav-backdrop.open { display: block; }

.mobile-nav-drawer {
  position: fixed; top: 0; right: -100%; z-index: 81;
  width: min(300px, 82vw); height: 100vh; overflow-y: auto;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-strong);
  display: flex; flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  padding-bottom: 30px;
}
.mobile-nav-drawer.open { right: 0; }

.mobile-nav-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.mobile-nav-header .brand-logo { height: 26px; }

.mobile-nav-links { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; }
.mobile-nav-links .sidebar-link { border-radius: var(--radius-sm); font-size: 15px; padding: 12px 14px; }
.mobile-nav-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-faint); padding: 14px 14px 5px; font-weight: 700;
}
.mobile-nav-divider { height: 1px; background: var(--border); margin: 8px 12px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,.3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,.5); }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .app-shell { padding: 16px 14px 90px; }
  .post-images-preview img { height: 160px; }
  .post-images-preview.single-img img { height: 220px; }
  /* Show hamburger, hide static sidebar */
  .hamburger-btn { display: flex; }
  /* Hide type/sort filter chips on mobile – accessible via hamburger drawer */
  .feed-tabs { display: none; }
}

@media (max-width: 640px) {
  .search-box { display: none; }
  .topbar-inner { gap: 8px; }
  .ai-panel { left: 10px; right: 10px; width: auto; }
  .ai-fab { left: 14px; bottom: 14px; }
  .post-detail-title { font-size: 20px; }
  .admin-stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-table th, .admin-table td { padding: 10px 10px; }
  .vote-col { min-width: 38px; }
  .vote-btn { width: 34px; height: 30px; }
  .post-detail-images img { max-height: 300px; }
  .communities-grid { grid-template-columns: 1fr; }
  .form-card { padding: 20px 16px; }
  .profile-cover { height: 120px; }
  /* Create-mode toggle on mobile */
  .create-mode-toggle { flex-direction: column; }
  .mode-btn { flex: unset; }
}

@media (max-width: 400px) {
  .app-shell { padding: 12px 10px 80px; }
  .topbar-inner { padding: 8px 10px; }
  .post-title { font-size: 15px; }
  .nav-actions { gap: 6px; }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ===== Image Lightbox ===== */
.img-lightbox-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.88); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade-in 0.18s ease;
}
.img-lightbox-box {
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); overflow: hidden;
  max-width: min(90vw, 700px); width: 100%;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7);
  display: flex; flex-direction: column;
  animation: lb-pop 0.2s cubic-bezier(.4,0,.2,1);
}
@keyframes lb-pop { from { opacity: 0; transform: scale(.94) translateY(12px); } to { opacity: 1; transform: none; } }

.img-lightbox-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: rgba(139,92,246,.07);
}
.img-lightbox-title {
  font-size: 14px; font-weight: 600; color: var(--text-dim);
}
.img-lightbox-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--gradient); color: white; border: none;
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: opacity var(--transition);
}
.img-lightbox-btn:hover { opacity: .88; }
.img-lightbox-btn:disabled { opacity: .45; cursor: not-allowed; }
.img-lightbox-close {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.07); border: 1px solid var(--border);
  color: var(--text-dim); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--transition), color var(--transition);
}
.img-lightbox-close:hover { background: rgba(248,113,113,.15); color: var(--danger); border-color: rgba(248,113,113,.3); }

.img-lightbox-img-wrap {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 220px; padding: 16px; background: var(--bg);
}
.img-lightbox-spinner {
  position: absolute; display: flex; align-items: center; justify-content: center;
}
.img-lightbox-img {
  max-width: 100%; max-height: 72vh; border-radius: var(--radius-sm);
  object-fit: contain; display: block; opacity: 0;
  transition: opacity 0.25s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

/* ── Disabled paper tool states ── */
.tool-card-disabled {
  opacity: .75;
  pointer-events: none;
  border-color: rgba(248,113,113,.15) !important;
}
.tool-card-header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.tool-disabled-tag {
  margin-right: auto;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(248,113,113,.12); color: var(--danger);
  border: 1px solid rgba(248,113,113,.22);
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}
.tool-unavailable-msg {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; margin-top: 4px;
  background: rgba(248,113,113,.06);
  border: 1px solid rgba(248,113,113,.14);
  border-radius: var(--radius-sm);
  color: var(--danger); font-size: 14px; font-weight: 600;
  pointer-events: none;
}

/* Disabled paper badge inside comment threads */
.paper-disabled-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(248,113,113,.08); color: var(--danger);
  border: 1px dashed rgba(248,113,113,.25);
  padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; opacity: .8;
}
