:root {
  --brand-purple: #584684;
  --brand-purple-dark: #4e3b7d;
  --brand-purple-deep: #130339;
  --brand-purple-light: #7a64b6;
  --brand-gold: #e0c9a3;
  --brand-gold-dark: #7c612f;
  --brand-cream: #fff9ee;
  --text-main: #130339;
  --text-muted: #6e6585;
  --text-light: #8b7fa3;
  --bg-body: #f8f8f8;
  --bg-card: #ffffff;
  --border: rgba(19, 3, 57, 0.1);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f4a261;
  --info: #584684;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(19, 3, 57, 0.08);
  --shadow-lg: 0 18px 60px rgba(19, 3, 57, 0.14);
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-purple); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: min(1180px, 92%);
  margin: 0 auto;
}

/* Header */
.site-header {
  background: var(--brand-purple-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
  gap: 24px;
}
.brand img { height: 48px; width: auto; display: block; filter: drop-shadow(0 12px 18px rgba(0,0,0,0.18)); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.nav-links a {
  color: rgba(255,255,255,0.88);
  font-weight: 500;
  font-size: 14px;
  border-radius: 999px;
  padding: 10px 16px;
}
.nav-links a:hover { background: rgba(224, 201, 163, 0.17); color: var(--brand-gold); text-decoration: none; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 12px 25px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); text-decoration: none; }
.btn-primary { background: var(--brand-purple); color: #fff; box-shadow: 0 16px 34px rgba(88, 70, 132, 0.22); }
.btn-primary:hover { background: var(--brand-purple-deep); }
.btn-gold { background: var(--brand-gold); color: var(--brand-purple-deep); }
.btn-gold:hover { background: #fff; box-shadow: 0 16px 34px rgba(224, 201, 163, 0.18); }
.btn-outline { background: transparent; border-color: rgba(255,255,255,0.28); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.12); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-body); }

.mobile-menu-toggle {
  display: none;
  border: 0;
  border-radius: 999px;
  background: var(--brand-gold);
  color: var(--brand-purple-deep);
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* Notifications bell + dropdown */
.notif-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.notif-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 999px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  transition: background .2s ease;
}

.notif-trigger:hover {
  background: rgba(224, 201, 163, 0.2);
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  box-sizing: border-box;
}

.notif-menu {
  display: none;
  position: absolute;
  top: 52px;
  right: 0;
  width: min(360px, 92vw);
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 300;
}

.notif-menu.open { display: block; }

.notif-menu-head {
  padding: 14px 18px;
  font-weight: 800;
  font-size: 15px;
  color: var(--brand-purple-deep);
  border-bottom: 1px solid var(--border);
}

.notif-list {
  max-height: 320px;
  overflow-y: auto;
}

.notif-item {
  display: block;
  padding: 12px 18px;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background .15s ease;
}

.notif-item:hover {
  background: var(--bg-body);
  text-decoration: none;
}

.notif-item.unread { background: var(--brand-cream); }

.notif-item.unread .notif-msg::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 8px;
}

.notif-msg {
  display: block;
  font-size: 14px;
  color: var(--text-main);
  font-weight: 500;
}

.notif-ago {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.notif-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

@media (max-width: 860px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    background: var(--brand-purple-dark);
    padding: 20px;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-lg);
  }
  .mobile-menu-toggle { display: block; }

  .notif-menu {
    position: fixed;
    top: 76px;
    right: 12px;
    left: auto;
    width: min(360px, calc(100vw - 24px));
  }
}

/* Hero */
.hero {
  background: var(--brand-purple-dark);
  color: #fff;
  padding: 90px 0 110px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(38px, 5.7vw, 64px);
  font-weight: 700;
  margin: 0 0 18px;
  line-height: 1.12;
  letter-spacing: -0.04em;
}
.hero p {
  font-size: 17px;
  color: var(--brand-gold);
  max-width: 650px;
  margin: 0 auto 36px;
}
.search-box {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
}
.search-box input {
  width: 100%;
  padding: 18px 58px 18px 24px;
  border-radius: 999px;
  border: none;
  font-size: 16px;
  box-shadow: var(--shadow-lg);
  outline: none;
  color: var(--text-main);
}
.search-box button {
  position: absolute;
  right: 7px;
  top: 7px;
  bottom: 7px;
  padding: 0 24px;
  border-radius: 999px;
  border: none;
  background: var(--brand-purple);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.search-box button:hover { background: var(--brand-purple-deep); }
.search-suggestions {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  text-align: left;
  z-index: 50;
}
.search-suggestions a {
  display: block;
  padding: 14px 22px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
}
.search-suggestions a:hover { background: var(--bg-body); text-decoration: none; }
.search-suggestions small { color: var(--text-muted); display: block; font-size: 13px; }

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-body { padding: 28px; }
.card-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--brand-purple-deep);
}

.section { padding: 80px 0; }
.section-title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin: 0 0 12px;
  color: var(--brand-purple-deep);
}
.section-subtitle {
  color: var(--text-muted);
  margin: 0 0 36px;
  font-size: 16px;
}

/* Post list */
.post-list { display: grid; gap: 18px; }
.post-card {
  display: flex;
  gap: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.post-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 48px;
}
.vote-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 20px;
  cursor: pointer;
  padding: 2px;
}
.vote-btn:hover { color: var(--brand-purple); }
.vote-btn.active { color: var(--brand-purple); }
.vote-count {
  font-weight: 800;
  font-size: 16px;
  color: var(--brand-purple-deep);
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.post-meta span { display: inline-flex; align-items: center; gap: 5px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-category { background: var(--brand-cream); color: var(--brand-gold-dark); }
.badge-answered { background: rgba(16, 185, 129, 0.12); color: #047857; }
.badge-staff { background: var(--brand-purple); color: #fff; }
.badge-pending { background: rgba(224, 201, 163, 0.22); color: var(--brand-gold-dark); }
.badge-unverified { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.post-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--brand-purple-deep);
}
.post-title a:hover { color: var(--brand-purple); text-decoration: none; }
.post-excerpt {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

/* Question detail */
.question-detail { padding-bottom: 50px; }

.question-hero {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 50px 0;
  box-shadow: 0 4px 24px rgba(19, 3, 57, 0.05);
}

.question-hero .answer-card {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin-bottom: 0;
}

.question-card .question-content {
  border-left: 4px solid var(--brand-purple-light);
  padding-left: 28px;
}

.question-card h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--brand-purple-deep);
}

.question-card .question-body {
  font-size: 17px;
  line-height: 1.75;
}

@media (max-width: 640px) {
  .question-card h1 {
    font-size: 26px;
  }

  .question-card .question-content {
    padding-left: 18px;
  }
}

/* Collapsible comment forms */
.comment-form-details summary {
  list-style: none;
  cursor: pointer;
}

.comment-form-details summary::-webkit-details-marker {
  display: none;
}

.comment-form-details[open] summary {
  margin-bottom: 12px;
}
.question-header { margin-bottom: 24px; }
.question-header h1 { font-size: 30px; font-weight: 700; margin: 0 0 12px; color: var(--brand-purple-deep); }
.question-body, .answer-body, .comment-body {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-main);
}
.question-body img, .answer-body img { max-width: 100%; border-radius: 14px; }
.answer-card {
  display: flex;
  gap: 18px;
  padding: 26px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  margin-bottom: 18px;
}
.answer-accepted { border-color: var(--success); background: rgba(16, 185, 129, 0.06); }
.accept-btn {
  background: transparent;
  border: 1px solid var(--success);
  color: var(--success);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.accept-btn.accepted { background: var(--success); color: #fff; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--brand-purple-deep);
}
.form-control {
  width: 100%;
  min-height: 48px;
  padding: 13px 15px;
  border: 1px solid rgba(19, 3, 57, 0.14);
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--brand-purple-deep);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.form-control:focus {
  border-color: var(--brand-purple-light);
  box-shadow: 0 0 0 4px rgba(122, 100, 182, 0.12);
}
textarea.form-control { min-height: 140px; resize: vertical; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* Auth pages */
.auth-page { padding: 80px 0; }
.auth-card {
  max-width: 480px;
  margin: 0 auto;
  padding: 38px;
  border-radius: 24px;
}
.auth-card h2 { margin: 0 0 8px; font-size: 28px; color: var(--brand-purple-deep); }
.auth-card p.sub { color: var(--text-muted); margin: 0 0 28px; }

/* Footer */
.site-footer {
  background: var(--brand-purple-dark);
  color: rgba(255,255,255,.78);
  padding: 70px 0 34px;
  margin-top: 80px;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 40px;
  margin-bottom: 46px;
}
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.site-footer h3 {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 16px;
}
.site-footer a { color: rgba(255,255,255,.78); display: block; margin-bottom: 8px; }
.site-footer a:hover { color: var(--brand-gold); text-decoration: none; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 24px;
  text-align: center;
  font-size: 14px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(19, 3, 57, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: 22px;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 26px 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { margin: 0; font-size: 22px; color: var(--brand-purple-deep); }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-body { padding: 20px 28px 28px; }

.modal .btn-outline,
.card .btn-outline {
  background: transparent;
  border-color: var(--brand-purple);
  color: var(--brand-purple);
}

.modal .btn-outline:hover,
.card .btn-outline:hover {
  background: var(--brand-purple);
  color: #fff;
}

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 600;
}
.alert-success { background: rgba(16, 185, 129, 0.12); color: #047857; }
.alert-danger { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.alert-info { background: rgba(122, 100, 182, 0.12); color: var(--brand-purple-deep); }

/* Utility */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 24px; }
.mb-4 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 12px; }
.gap-4 { gap: 24px; }
.hidden { display: none !important; }

/* Admin */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 260px;
  background: var(--brand-purple-dark);
  color: #fff;
  padding: 24px;
}
.admin-sidebar a {
  display: block;
  color: rgba(255,255,255,.8);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(224, 201, 163, 0.17); color: var(--brand-gold); text-decoration: none; }
.admin-main { flex: 1; padding: 32px; background: var(--bg-body); }
.admin-card { background: #fff; border-radius: 20px; padding: 26px; box-shadow: var(--shadow); border: 1px solid var(--border); }

.ask-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .ask-layout { grid-template-columns: 1fr; }
}

.file-upload-area {
  position: relative;
  border: 2px dashed rgba(19, 3, 57, 0.18);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  background: var(--bg-body);
  color: var(--text-muted);
  transition: border-color .2s ease, background .2s ease;
  cursor: pointer;
}

.file-upload-area:hover, .file-upload-area.dragover {
  border-color: var(--brand-purple);
  background: rgba(122, 100, 182, 0.06);
}

.file-upload-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-prompt p { margin: 0; }

.file-upload-area-sm {
  padding: 18px;
  border-radius: 14px;
}

.file-upload-area-sm .file-upload-prompt svg {
  display: block;
  margin: 0 auto 6px;
}

.attachments-list {
  display: grid;
  gap: 12px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg-body);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.attachment-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
}

.attachment-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: #fff;
  border-radius: 8px;
  flex-shrink: 0;
}

.attachment-info {
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-purple-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.attachment-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.attachment-uploading {
  opacity: 0.7;
}

.attachments-section {
  margin-top: 24px;
  padding: 18px;
  background: var(--bg-body);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.attachment-tile {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}

.attachment-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.attachment-tile-thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.attachment-tile-icon {
  width: 100%;
  height: 100px;
  display: grid;
  place-items: center;
  font-size: 32px;
  background: #fff;
}

.attachment-tile-name {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Question page layout: main column + attachments sidebar */
.question-hero-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}

.question-main {
  min-width: 0;
}

.question-sidebar {
  position: sticky;
  top: 100px;
}

.attachments-sidebar-card .attachments-grid {
  grid-template-columns: 1fr;
  gap: 14px;
}

.attachments-sidebar-card .attachment-tile-thumb,
.attachments-sidebar-card .attachment-tile-icon {
  height: 160px;
}

@media (max-width: 860px) {
  .question-hero-layout {
    grid-template-columns: 1fr;
  }
  .question-sidebar {
    position: static;
  }
}

/* Markdown content */
.markdown h1, .markdown h2, .markdown h3 { margin-top: 24px; margin-bottom: 12px; color: var(--brand-purple-deep); }
.markdown p { margin-bottom: 14px; }
.markdown pre {
  background: #f7f4ff;
  padding: 16px;
  border-radius: 14px;
  overflow-x: auto;
}
.markdown code { background: #f7f4ff; padding: 2px 6px; border-radius: 4px; }
.markdown blockquote { border-left: 4px solid var(--brand-gold); padding-left: 16px; color: var(--text-muted); margin: 16px 0; }
.markdown ul, .markdown ol { padding-left: 24px; }

/* Comments */
.comment {
  padding: 14px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.comment-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
