/* ================================================================
   DOREW — SForum-inspired Design System
   Stack: Bootstrap 4.5.3 · jQuery 3.7.1 · Plates PHP · PHP 8.1+
   Layout: Sticky topbar · Left sidebar · Main content · Right rail
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Be+Vietnam+Pro:wght@400;500;600;700&display=swap');

/* ── 1. Design Tokens ─────────────────────────────────────── */
:root {
  /* Accent — Red Gradient (SForum-inspired) */
  --accent:          #d70018;
  --accent-hover:    #b30014;
  --accent-soft:     #fce5e8;
  --accent-soft-bd:  #f3b3bc;
  --accent-rgb:      215 0 24;
  --accent-gradient: linear-gradient(135deg, #ff4b2b, #ff416c);

  /* Surfaces */
  --bg:              #f5f5f8;
  --surface:         #ffffff;
  --surface-muted:   #f5f5f8;
  --card:            #ffffff;

  /* Foreground */
  --fg:              #1a1a2e;
  --fg-secondary:    #52525b;
  --fg-muted:        #a1a1aa;
  --fg-faint:        #c4c4cc;

  /* Border */
  --border:          #e4e4e7;
  --border-muted:    #f0f0f3;
  --border-strong:   #d4d4d8;

  /* Status */
  --success:         #15803d;
  --success-soft:    #dcfce7;
  --danger:          #b91c1c;
  --danger-soft:     #fee2e2;
  --warning:         #b45309;
  --warning-soft:    #fef3c7;
  --info:            #1d4ed8;
  --info-soft:       #dbeafe;

  /* Shadows */
  --shadow-sm:       0 1px 2px rgb(0 0 0 / .05);
  --shadow:          0 1px 3px rgb(0 0 0 / .07), 0 1px 2px rgb(0 0 0 / .05);
  --shadow-md:       0 4px 6px rgb(0 0 0 / .06), 0 2px 4px rgb(0 0 0 / .04);

  /* Layout */
  --sidebar-w:       220px;
  --right-rail-w:    250px;
  --topbar-h:        56px;
  --radius:          8px;
  --radius-sm:       5px;
  --radius-lg:       12px;

  /* Typography */
  --font-sans:       'Inter', 'Be Vietnam Pro', system-ui, sans-serif;
  --font-body-size:  14.5px;
}

/* ── Dark Mode ────────────────────────────────────────────── */
body.dark-mode {
  --bg:              #0f1011;
  --surface:         #18181b;
  --surface-muted:   #27272a;
  --card:            #1c1c1f;
  --fg:              #f4f4f5;
  --fg-secondary:    #d4d4d8;
  --fg-muted:        #71717a;
  --fg-faint:        #3f3f46;
  --border:          #3f3f46;
  --border-muted:    #2a2a2e;
  --border-strong:   #52525b;
  --accent-soft:     rgba(15, 118, 110, .16);
  --accent-soft-bd:  rgba(15, 118, 110, .35);
  --shadow-sm:       0 1px 3px rgb(0 0 0 / .25);
  --shadow:          0 1px 4px rgb(0 0 0 / .30);
  --shadow-md:       0 4px 12px rgb(0 0 0 / .35);
  --success-soft:    rgba(21, 128, 61, .2);
  --danger-soft:     rgba(185, 28, 28, .2);
  --warning-soft:    rgba(180, 83, 9, .2);
  --info-soft:       rgba(29, 78, 216, .2);
}

/* ── 2. Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  overflow-y: scroll;
}

body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--font-body-size);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  word-wrap: break-word;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); text-decoration: none; }

img { max-width: 100%; height: auto; display: block; }
p { margin: 0 0 .6rem; }
ul { padding-left: 1.25rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
h1,h2,h3,h4,h5 { font-weight: 700; line-height: 1.3; color: var(--fg); margin: 0 0 .5rem; }

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

::selection { background: rgba(15, 118, 110, .18); }

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

/* ── 3. Layout Shell ──────────────────────────────────────── */

/* Topbar */
#dw-topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

/* Logo */
.dw-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--accent) !important;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.dw-logo::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Search bar */
.dw-search-wrap {
  flex: 1;
  max-width: 400px;
}
.dw-search-wrap .form-control {
  border-radius: 20px;
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--fg);
  font-size: 13px;
  height: 34px;
  padding: 0 14px;
  transition: border-color .2s, box-shadow .2s;
}
.dw-search-wrap .form-control:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}

/* Topbar right actions */
.dw-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.dw-topbar-actions .dw-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--fg-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.dw-topbar-actions .dw-icon-btn:hover {
  background: var(--surface-muted);
  color: var(--fg);
}
.dw-badge-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}
.dw-badge-num {
  position: absolute;
  top: 1px; right: 1px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  padding: 0 3px;
  border: 1.5px solid var(--surface);
}

/* Body layout — 3 columns on desktop */
#dw-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
#dw-body.has-right-rail {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--right-rail-w);
}

/* Left sidebar */
#dw-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 0 24px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
}

/* Main content */
#dw-main {
  min-width: 0;
  padding: 16px;
}

/* Right rail */
#dw-right {
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 12px;
}

/* ── 4. Sidebar Navigation ────────────────────────────────── */

.dw-nav-section {
  padding: 6px 8px 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 8px;
}

.dw-nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  margin: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.dw-nav-link:hover {
  background: var(--surface-muted);
  color: var(--fg);
  text-decoration: none;
}
.dw-nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.dw-nav-link .dw-nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 14px;
  opacity: .75;
}
.dw-nav-link.active .dw-nav-icon { opacity: 1; }
.dw-nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  padding: 0 4px;
}

/* Sidebar user card */
.dw-sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  margin: 4px 6px 8px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}
.dw-sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}
.dw-sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dw-sidebar-user-role {
  font-size: 11px;
  color: var(--fg-muted);
}

/* ── 5. Cards ─────────────────────────────────────────────── */

.dw-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 12px;
}
.dw-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.dw-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}
.dw-card-title .fa { color: var(--accent); font-size: 15px; }
.dw-card-body { padding: 14px 16px; }
.dw-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

/* ── 6. Forum Category Row (home list) ────────────────────── */

.dw-category-row {
  border-bottom: 1px solid var(--border);
}
.dw-category-row:last-child { border-bottom: none; }

.dw-category-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 70px 70px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  transition: background .15s;
}
.dw-category-item:hover { background: var(--surface-muted); }

.dw-cat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}
.dw-cat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}
.dw-cat-name a { color: inherit; }
.dw-cat-name a:hover { color: var(--accent); }
.dw-cat-desc {
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dw-cat-stat {
  text-align: center;
}
.dw-cat-stat-num {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.1;
}
.dw-cat-stat-label {
  font-size: 10.5px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Forum section header */
.dw-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}
.dw-section-header-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--fg-muted);
}

/* ── 7. Post List Row ─────────────────────────────────────── */

.dw-post-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 90px;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.dw-post-row:last-child { border-bottom: none; }
.dw-post-row:hover { background: var(--surface-muted); }

.dw-post-row-new .dw-post-title a { font-weight: 700; }

.dw-post-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dw-post-topic-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--fg-muted);
  font-size: 12px;
}
.dw-post-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dw-post-title a { color: inherit; }
.dw-post-title a:hover { color: var(--accent); }
.dw-post-meta {
  font-size: 11.5px;
  color: var(--fg-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dw-post-stat {
  text-align: right;
  font-size: 12px;
  color: var(--fg-secondary);
}
.dw-post-stat span { display: block; }
.dw-post-stat .dw-post-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

/* ── 8. Post Detail Page ──────────────────────────────────── */

.dw-post-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}

/* Breadcrumb */
.dw-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--fg-muted);
  flex-wrap: wrap;
}
.dw-breadcrumb a { color: var(--fg-secondary); }
.dw-breadcrumb a:hover { color: var(--accent); }
.dw-breadcrumb-sep { color: var(--fg-faint); }
.dw-breadcrumb-current { color: var(--fg); font-weight: 500; }

/* Post header */
.dw-post-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.dw-post-header h1 {
  font-size: 1.35rem;
  line-height: 1.35;
  margin-bottom: 10px;
}
.dw-post-header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dw-post-header-meta .dw-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--fg-muted);
}
.dw-post-header-meta .dw-meta-chip .fa { font-size: 11px; }
.dw-post-header-meta a { color: var(--fg-secondary); }
.dw-post-header-meta a:hover { color: var(--accent); }

/* Author sidebar inside post */
.dw-post-layout {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
}

.dw-post-author-col {
  border-right: 1px solid var(--border);
  background: var(--surface-muted);
}
.dw-post-author-sticky {
  position: sticky;
  top: 70px;
  padding: 16px 12px;
  text-align: center;
}
.dw-post-author-sticky .dw-avt {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 8px;
  border: 2px solid var(--border);
}

@media (max-width: 600px) {
  .dw-post-layout { grid-template-columns: 1fr; }
  .dw-post-author-col {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .dw-post-author-sticky {
    display: flex;
    align-items: center;
    text-align: left;
    padding: 12px 16px;
    position: static; /* Remove sticky on mobile */
  }
  .dw-post-author-sticky .dw-avt {
    margin: 0 12px 0 0;
    width: 48px; height: 48px;
  }
  .dw-post-author-name {
    margin-bottom: 0;
  }
  .dw-post-author-status,
  .dw-post-author-stats {
    display: none; /* Hide extra stats on mobile to keep it compact like default */
  }
}
.dw-post-author-name {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  word-break: break-word;
}
.dw-post-author-name a { color: var(--fg); }
.dw-post-author-name a:hover { color: var(--accent); }
.dw-post-author-role {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 6px;
}
.dw-post-author-status {
  font-size: 11px;
  color: var(--fg-muted);
  font-style: italic;
  word-break: break-word;
  margin-top: 4px;
}
.dw-post-author-stats {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.dw-post-author-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--fg-muted);
  padding: 1px 0;
}
.dw-post-author-stat-row span:last-child {
  font-weight: 600;
  color: var(--fg-secondary);
}

/* Post body */
.dw-post-content-col {
  min-width: 0;
}
.dw-post-time-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 11.5px;
  color: var(--fg-muted);
}
.dw-post-body {
  padding: 18px 20px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--fg);
  min-height: 80px;
}

/* Post body content styling */
.dw-post-body img { border-radius: var(--radius-sm); margin: 8px 0; }
.dw-post-body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  padding: 8px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 8px 0;
  color: var(--fg-secondary);
}
.dw-post-body pre, .dw-post-body code {
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: .85em;
}
.dw-post-body pre {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
}

/* Post actions bar */
.dw-post-action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── 9. Comment ───────────────────────────────────────────── */

.dw-comment-wrap {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  background: var(--card);
}

.dw-comment {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  border-bottom: 1px solid var(--border);
}
.dw-comment:last-child { border-bottom: none; }
.dw-comment-author-col {
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  background: var(--surface-muted);
  text-align: center;
}
.dw-comment-author-col .dw-avt {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 5px;
  border: 1.5px solid var(--border);
}
.dw-comment-author-name {
  font-size: 11.5px;
  font-weight: 600;
  word-break: break-word;
}
.dw-comment-body { padding: 12px 14px; font-size: 14px; line-height: 1.7; }
.dw-comment-time { font-size: 11px; color: var(--fg-muted); margin-top: 8px; }

.dw-comment-form { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface-muted); }

@media (max-width: 600px) {
  .dw-comment { grid-template-columns: 1fr; }
  .dw-comment-author-col {
    display: flex;
    align-items: center;
    text-align: left;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
  }
  .dw-comment-author-col .dw-avt {
    margin: 0 10px 0 0;
    width: 32px; height: 32px;
  }
  .dw-comment-author-name {
    margin-bottom: 0;
  }
}

/* ── 10. Profile Page ─────────────────────────────────────── */

.dw-profile-cover {
  height: 160px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000));
  background-size: cover;
  background-position: center;
  position: relative;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
}
.dw-profile-cover-edit {
  position: absolute;
  bottom: 10px; right: 12px;
  background: rgba(0,0,0,.5);
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.dw-profile-cover-edit:hover { background: rgba(0,0,0,.75); color: #fff; }

.dw-profile-info-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
  background: var(--card);
  flex-wrap: wrap;
}
.dw-profile-avatar-wrap {
  margin-top: -40px;
  flex-shrink: 0;
  position: relative;
}
.dw-profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 3px solid var(--card);
  object-fit: cover;
  display: block;
  background: var(--surface-muted);
}
.dw-profile-avatar-edit {
  position: absolute;
  bottom: 0; right: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border: 2px solid var(--card);
}
.dw-profile-names { flex: 1; padding-top: 8px; min-width: 0; }
.dw-profile-names h2 { font-size: 1.1rem; margin-bottom: 2px; }
.dw-profile-nick { font-size: 13px; color: var(--fg-muted); }
.dw-profile-status { font-size: 13px; color: var(--fg-secondary); font-style: italic; margin-top: 2px; }
.dw-profile-actions { margin-left: auto; padding-top: 8px; display: flex; gap: 8px; }

.dw-profile-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  overflow-x: auto;
}
.dw-profile-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.dw-profile-tab.active, .dw-profile-tab:hover { color: var(--accent); }
.dw-profile-tab.active { border-bottom-color: var(--accent); }

/* Profile stats row */
.dw-profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  text-align: center;
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.dw-profile-stat-item { padding: 8px; }
.dw-profile-stat-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
}
.dw-profile-stat-label { font-size: 11px; color: var(--fg-muted); margin-top: 2px; }

/* ── 11. Buttons ──────────────────────────────────────────── */

.dw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.dw-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.dw-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.dw-btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent-soft-bd);
}
.dw-btn-outline:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.dw-btn-ghost {
  background: transparent;
  color: var(--fg-secondary);
  border-color: var(--border);
}
.dw-btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--fg);
}
.dw-btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.dw-btn-sm { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.dw-btn-lg { padding: 10px 20px; font-size: 15px; }
.dw-btn-block { display: flex; width: 100%; }

/* ── 12. Form Controls ────────────────────────────────────── */

.dw-form-group { margin-bottom: 14px; }
.dw-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-secondary);
  margin-bottom: 5px;
}
.dw-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .2s, box-shadow .2s;
}
.dw-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
  outline: none;
}
.dw-input::placeholder { color: var(--fg-faint); }
.dw-input.is-invalid { border-color: var(--danger); }
.dw-textarea { resize: vertical; min-height: 120px; }
.dw-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ── 13. Badges & Tags ────────────────────────────────────── */

.dw-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.dw-badge-success { background: var(--success-soft); color: var(--success); }
.dw-badge-danger  { background: var(--danger-soft);  color: var(--danger);  }
.dw-badge-warning { background: var(--warning-soft); color: var(--warning); }
.dw-badge-info    { background: var(--info-soft);    color: var(--info);    }
.dw-badge-accent  { background: var(--accent-soft);  color: var(--accent);  }
.dw-badge-muted   { background: var(--surface-muted); color: var(--fg-muted); border: 1px solid var(--border); }

.dw-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--fg-secondary);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.dw-tag:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft-bd);
  color: var(--accent);
}

/* ── 14. Avatar ───────────────────────────────────────────── */

.dw-avt {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-muted);
  display: block;
}

/* ── 15. Alert / Notice ───────────────────────────────────── */

.dw-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 12px;
  font-size: 13.5px;
}
.dw-alert-success { background: var(--success-soft); border-color: #86efac; color: #15803d; }
.dw-alert-danger  { background: var(--danger-soft);  border-color: #fca5a5; color: #b91c1c; }
.dw-alert-warning { background: var(--warning-soft); border-color: #fcd34d; color: #92400e; }
.dw-alert-info    { background: var(--info-soft);    border-color: #93c5fd; color: #1e40af; }

/* ── 16. Pagination ───────────────────────────────────────── */

.dw-pagination {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.dw-pagination a, .dw-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-secondary);
  padding: 0 6px;
  transition: all .15s;
}
.dw-pagination a:hover {
  background: var(--surface-muted);
  color: var(--fg);
  text-decoration: none;
}
.dw-pagination .active span, .dw-pagination .active a {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── 17. Right Rail ───────────────────────────────────────── */

.dw-rail-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--card);
}
.dw-rail-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dw-rail-header .fa { color: var(--accent); }
.dw-rail-body { padding: 8px 0; }

.dw-rail-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  font-size: 13px;
  transition: background .15s;
}
.dw-rail-row:hover { background: var(--surface-muted); }
.dw-rail-row .dw-avt { width: 28px; height: 28px; }

/* ── 18. Mail / Inbox ─────────────────────────────────────── */

.dw-mail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  cursor: pointer;
}
.dw-mail-item:hover { background: var(--surface-muted); }
.dw-mail-item:last-child { border-bottom: none; }
.dw-mail-item.unread .dw-mail-subject { font-weight: 700; }
.dw-mail-item.unread { background: linear-gradient(to right, rgba(15,118,110,.04), transparent); }
.dw-mail-avt { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-muted); }
.dw-mail-body { flex: 1; min-width: 0; }
.dw-mail-sender { font-size: 13px; font-weight: 600; color: var(--fg); }
.dw-mail-subject { font-size: 13px; color: var(--fg-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dw-mail-preview { font-size: 12px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dw-mail-time { font-size: 11px; color: var(--fg-muted); flex-shrink: 0; }
.dw-mail-unread-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── 19. Shoutbox / Chat ──────────────────────────────────── */

.dw-chat-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
  margin-bottom: 12px;
}
.dw-chat-msg {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-muted);
  transition: background .15s;
}
.dw-chat-msg:hover { background: var(--surface-muted); }
.dw-chat-msg:last-child { border-bottom: none; }
.dw-chat-avt { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-muted); }
.dw-chat-right { flex: 1; min-width: 0; }
.dw-chat-author { font-size: 12.5px; font-weight: 600; color: var(--fg); margin-bottom: 3px; display: flex; align-items: center; gap: 8px; }
.dw-chat-time { font-size: 11px; color: var(--fg-muted); font-weight: 400; }
.dw-chat-text { font-size: 13.5px; color: var(--fg); line-height: 1.6; word-break: break-word; }
.dw-chat-text img { border-radius: var(--radius-sm); max-height: 200px; width: auto; display: inline; }
.dw-chat-form-wrap { padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-muted); }

/* ── 20. Toolbar (BBCode editor) ──────────────────────────── */

.dw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.dw-toolbar-btn {
  width: 30px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--fg-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.dw-toolbar-btn:hover { background: var(--border); color: var(--fg); }
.dw-toolbar-sep { width: 1px; background: var(--border); margin: 3px 2px; align-self: stretch; }
.dw-toolbar + .dw-input, .dw-toolbar + textarea {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Emoji / color dropdown */
.dw-toolbar-dropdown {
  display: none;
  position: absolute;
  z-index: 500;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
  max-width: 280px;
  max-height: 200px;
  overflow-y: auto;
}
.dw-toolbar-dropdown.open { display: block; }

/* ── 21. Auth Pages (Login / Register) ────────────────────── */

.dw-auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--topbar-h));
  padding: 24px 16px;
}
.dw-auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.dw-auth-card-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.dw-auth-card-header h2 { font-size: 1.2rem; margin: 0; }
.dw-auth-card-header p { font-size: 13px; color: var(--fg-muted); margin: 4px 0 0; }
.dw-auth-card-body { padding: 20px 24px; }
.dw-auth-card-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 13px;
  text-align: center;
  color: var(--fg-muted);
}

/* ── 22. Toast Notifications ──────────────────────────────── */

#dw-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.dw-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--fg);
  animation: dw-slide-in .25s ease;
  position: relative;
}
.dw-toast.success { border-left: 3px solid var(--success); }
.dw-toast.danger  { border-left: 3px solid var(--danger);  }
.dw-toast.info    { border-left: 3px solid var(--accent);  }
@keyframes dw-slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── 23. Footer ───────────────────────────────────────────── */

#dw-footer {
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--surface);
  text-align: center;
}
#dw-footer a { color: var(--fg-muted); }
#dw-footer a:hover { color: var(--accent); }

/* ── 24. Mobile bottom nav ────────────────────────────────── */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: 54px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 1000;
  box-shadow: 0 -2px 8px rgb(0 0 0 / .07);
  display: flex; /* Always display flex but only visible on mobile query */
}
@media (min-width: 981px) {
  .bottom-nav { display: none !important; }
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--fg-muted);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: color .15s;
  position: relative;
  text-decoration: none;
}
.bottom-nav a .fa { font-size: 18px; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--accent); }
.bottom-nav a .dw-badge-dot { top: 6px; right: calc(50% - 14px); }

/* ── 25. Utility Classes ──────────────────────────────────── */

.dw-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-muted);
  font-size: 12px;
  margin: 14px 0;
}
.dw-divider::before, .dw-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

.dw-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-muted);
}
.dw-empty-state .fa { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; display: block; }
.dw-empty-state p { font-size: 14px; margin: 0; }

.dw-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: var(--fg-muted);
  gap: 8px;
}
.dw-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dw-spin .7s linear infinite;
}
@keyframes dw-spin { to { transform: rotate(360deg); } }

/* Lazy load fade-in */
.lozad { opacity: 0; transition: opacity .35s ease; }
.lozad[data-loaded="true"] { opacity: 1; }

/* Fade in on scroll */
.dw-fade-in {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .4s ease, transform .4s ease;
}
.dw-fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── 26. Responsive ───────────────────────────────────────── */

@media (max-width: 980px) {
  #dw-sidebar { display: none; }
  #dw-body {
    grid-template-columns: minmax(0, 1fr);
  }
  #dw-body.has-right-rail {
    grid-template-columns: minmax(0, 1fr);
  }
  #dw-right { display: none; }
  .bottom-nav { display: flex; }
  body { padding-bottom: 54px; }
  #dw-main { padding: 10px; }
}

@media (max-width: 600px) {
  .dw-category-item {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .dw-cat-stat:not(:first-of-type) { display: none; }
  .dw-post-row {
    grid-template-columns: minmax(0, 1fr) 60px;
  }
  .dw-post-row > :last-child { display: none; }
  .dw-post-header h1 { font-size: 1.1rem; }
  #dw-topbar .dw-search-wrap { display: none; }
  .dw-profile-avatar { width: 64px; height: 64px; }
  .dw-profile-cover { height: 120px; }
}

/* ── Override Bootstrap conflicts ─────────────────────────── */
.card { background: var(--card); border-color: var(--border); color: var(--fg); }
.form-control {
  background: var(--surface);
  border-color: var(--border);
  color: var(--fg);
}
.form-control:focus {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .2);
}
.alert-warning { background: var(--warning-soft); border-color: #fcd34d; color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  border-color: #fca5a5; color: var(--danger);  }
.alert-success { background: var(--success-soft); border-color: #86efac; color: var(--success); }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Highlight.js override */
pre.hljs { border-radius: var(--radius-sm); margin: 10px 0; }