:root {
  --primary: #2c3e50;
  --primary-light: #34495e;
  --accent: #3498db;
  --accent-hover: #2980b9;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --success: #27ae60;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dcdde1;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 8px;
  --radius-sm: 4px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  background: var(--primary);
  padding: 0 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar .nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: 1px;
  padding: 0.4rem 0;
  line-height: 1.4;
}

.navbar .nav-links a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  margin-left: 1.5rem;
  font-size: 0.95rem;
  transition: color 0.2s ease;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.navbar .nav-links a:hover {
  color: #fff;
  border-bottom-color: var(--accent);
}

.search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-input {
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 0.9rem;
  width: 220px;
  transition: background 0.2s, border-color 0.2s;
}

.search-input::placeholder {
  color: rgba(255,255,255,0.55);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255,255,255,0.15);
}

.search-info {
  color: var(--text-light);
  font-size: 1rem;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

.result-count {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ── Container ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-light);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ── Typography ── */
h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-hover);
}

/* ── Post Cards (Index) ── */
.post-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.post-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.post-card .post-title {
  margin-bottom: 0.4rem;
}

.post-card .post-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease;
}

.post-card .post-title a:hover {
  color: var(--accent);
}

.post-card .post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.date-badge {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-light);
  background: var(--bg);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.post-card .post-excerpt {
  color: #555;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ── Article (Single Post) ── */
.article-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
}

.article-card .post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-card .post-header h1 {
  margin-bottom: 0.5rem;
  font-size: 2.2rem;
}

.article-card .post-header .post-meta {
  color: var(--text-light);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.article-card .post-content {
  font-size: 1.05rem;
  line-height: 1.9;
  color: #444;
}

.article-card .post-content p {
  margin-bottom: 1.2rem;
}

.back-link {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--text-light);
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--accent);
}

/* ── Admin Login Card ── */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-check input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-check label {
  margin-bottom: 0;
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Admin Table ── */
.admin-table-wrapper {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 1.5rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table thead {
  background: var(--primary);
  color: #fff;
}

.admin-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table td {
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tbody tr {
  transition: background 0.15s ease;
}

.admin-table tbody tr:nth-child(even) {
  background: #f8f9fa;
}

.admin-table tbody tr:hover {
  background: #eef2f7;
}

.admin-table .published-yes {
  color: var(--success);
  font-weight: 600;
}

.admin-table .published-no {
  color: var(--danger);
  font-weight: 600;
}

.admin-table .actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-table .actions form {
  margin: 0;
}

/* ── Bulk Actions ── */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}
.bulk-count {
  font-size: 0.85rem;
  color: var(--text-light);
}
.admin-table th:first-child,
.admin-table td:first-child {
  width: 40px;
  text-align: center;
}
.post-checkbox {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--accent);
}
#select-all {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Dashboard Header ── */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-header h1 {
  margin-bottom: 0;
}

/* ── Post Form ── */
.post-form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  max-width: 800px;
}

.post-form-card .form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.post-form-card .form-actions .back-link {
  margin-top: 0;
}

/* ── Error message ── */
.error {
  background: #fde8e8;
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid #f5c6cb;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
  font-size: 1.1rem;
}

/* ── Tags ── */
.tag-link, .tag-badge {
  display: inline-block;
  padding: 2px 10px;
  margin: 2px 4px 2px 0;
  font-size: 0.8rem;
  border-radius: 12px;
  background: #e8ecf0;
  color: #555;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.tag-link:hover, .tag-badge:hover {
  background: var(--accent);
  color: #fff;
}
.tag-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}
.tag-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
}
.tag-filter-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
  background: #f0f4f8;
  border-radius: 6px;
  font-size: 0.9rem;
}
.clear-filter {
  color: #999;
  text-decoration: none;
  font-size: 1.1rem;
  margin-left: auto;
}
.clear-filter:hover {
  color: var(--danger);
}
.post-tags {
  margin-top: 8px;
}

/* ── Post Content Images ── */
.post-content img,
.post-excerpt img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ── Tag summary ── */
.tag-summary {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.tag-summary h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .container {
    padding: 1.25rem 1rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .navbar .nav-brand {
    font-size: 1rem;
  }

  .nav-left {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .user-name {
    display: none;
  }

  .search-input {
    width: 140px;
  }

  .post-card {
    padding: 1.25rem;
  }

  .article-card {
    padding: 1.5rem;
  }

  .article-card .post-header h1 {
    font-size: 1.6rem;
  }

  .login-card {
    padding: 1.5rem;
    margin: 0 1rem;
  }

  .post-form-card {
    padding: 1.5rem;
  }

  .admin-table th,
  .admin-table td {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-table .actions {
    flex-direction: column;
    gap: 0.35rem;
  }

  .admin-table .actions .btn-sm {
    width: 100%;
    text-align: center;
  }

  /* ── Mobile Admin Tables: horizontal scroll ── */
  .admin-table-wrapper {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide less important columns per page type */

  /* Dashboard (posts): hide Views(3), Comments(4), Date(6) */
  form[id="bulk-form"] .admin-table th:nth-child(3),
  form[id="bulk-form"] .admin-table td:nth-child(3),
  form[id="bulk-form"] .admin-table th:nth-child(4),
  form[id="bulk-form"] .admin-table td:nth-child(4),
  form[id="bulk-form"] .admin-table th:nth-child(6),
  form[id="bulk-form"] .admin-table td:nth-child(6) {
    display: none;
  }

  /* Tags & Categories: hide Slug(2) */
  .dashboard-header ~ .admin-table-wrapper .admin-table th:nth-child(2),
  .dashboard-header ~ .admin-table-wrapper .admin-table td:nth-child(2) {
    display: none;
  }

  /* Comments page: hide Reply(2), Post(4), Status(5), Date(6) */
  h1 ~ .admin-table-wrapper .admin-table th:nth-child(2),
  h1 ~ .admin-table-wrapper .admin-table td:nth-child(2),
  h1 ~ .admin-table-wrapper .admin-table th:nth-child(4),
  h1 ~ .admin-table-wrapper .admin-table td:nth-child(4),
  h1 ~ .admin-table-wrapper .admin-table th:nth-child(5),
  h1 ~ .admin-table-wrapper .admin-table td:nth-child(5),
  h1 ~ .admin-table-wrapper .admin-table th:nth-child(6),
  h1 ~ .admin-table-wrapper .admin-table td:nth-child(6) {
    display: none;
  }

  /* Mobile action buttons — consistent: side by side, equal width */
  .admin-table .actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.35rem;
  }
  .admin-table .actions .btn-sm {
    flex: 1 1 0;
    min-width: 50px;
    max-width: 85px;
    text-align: center;
    font-size: 0.78rem;
    padding: 0.3rem 0.2rem;
    white-space: nowrap;
  }

  /* Dashboard: compact the checkbox column */
  #bulk-form .admin-table th:first-child,
  #bulk-form .admin-table td:first-child {
    padding-right: 0.25rem;
    width: 30px;
  }
  #bulk-form .post-checkbox {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 480px) {
  .navbar-inner {
    flex-direction: column;
    height: auto;
    padding: 0.75rem 0;
    gap: 0.5rem;
  }

  .nav-left {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .nav-right {
    width: 100%;
    justify-content: flex-end;
  }

  .search-form {
    width: 100%;
  }

  .navbar .nav-links a:first-child {
    margin-left: 0;
  }

  .navbar .search-input {
    flex: 1;
    padding: 0.35rem 0.6rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 0.9rem;
  }

  .navbar .search-input::placeholder {
    color: rgba(255,255,255,0.6);
  }

  .navbar .search-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255,255,255,0.15);
  }

  .post-card .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }

  /* Even more compact cells */
  .admin-table th,
  .admin-table td {
    padding: 0.4rem 0.3rem;
    font-size: 0.75rem;
  }
  .admin-table .actions .btn-sm {
    font-size: 0.7rem;
    padding: 0.2rem 0.3rem;
    min-width: 48px;
  }
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.pagination .page-info {
  font-size: 0.9rem;
  color: var(--text-light);
}

.status-published {
  color: #27ae60;
  font-weight: 600;
}
.status-draft {
  color: #e67e22;
  font-weight: 600;
}
.post-meta {
  font-size: 0.9rem;
  color: #7f8c8d;
  margin-bottom: 0.5rem;
}
.post-meta a {
  color: #3498db;
  text-decoration: none;
}
.post-meta a:hover {
  text-decoration: underline;
}

/* ===== Comments ===== */
.comments-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.comments-section h2 {
  margin-bottom: 1rem;
}

.comment {
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee;
}

.comment:last-child {
  border-bottom: none;
}

.comment-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.comment-author {
  font-size: 0.95rem;
}

.comment-date {
  font-size: 0.8rem;
  color: var(--text-light);
}

.comment-content {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.comment-form {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 6px;
}

.comment-form h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.comment-success {
  padding: 0.6rem 1rem;
  background: #d4edda;
  color: #155724;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.status-approved {
  color: #27ae60;
}

.status-pending {
  color: #f39c12;
}

.status-spam {
  color: #e74c3c;
}

.btn-warning {
  background: #f39c12;
  color: #fff;
}

.btn-warning:hover {
  background: #d68910;
}

.muted {
  color: var(--text-light);
  font-style: italic;
}

/* ── Markdown Editor Split Pane ── */
.editor-split {
  display: flex;
  gap: 1rem;
  min-height: 400px;
}
.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.editor-pane textarea.form-control {
  flex: 1;
  min-height: 350px;
  resize: vertical;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}
.preview-pane {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  padding: 0.5rem 0.75rem;
  background: #f5f6f8;
  border-bottom: 1px solid var(--border);
}
.preview-content {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  line-height: 1.7;
  font-size: 0.95rem;
}
.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4 {
  margin-top: 1em;
  margin-bottom: 0.5em;
}
.preview-content p {
  margin-bottom: 0.75em;
}
.preview-content code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85em;
}
.preview-content pre {
  background: #f5f5f5;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.preview-content pre code {
  background: none;
  padding: 0;
}
.preview-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}
.preview-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  margin-left: 0;
  color: var(--text-light);
}
.preview-content ul,
.preview-content ol {
  padding-left: 1.5rem;
  margin-bottom: 0.75em;
}
.preview-content a {
  color: var(--accent);
}

@media (max-width: 768px) {
  .editor-split {
    flex-direction: column;
  }
  .editor-pane textarea.form-control {
    min-height: 200px;
  }
  .preview-pane {
    min-height: 300px;
  }
}

/* ── Navbar Pages Dropdown ── */
.nav-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 1.5rem;
}
.nav-dropdown .dropbtn {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
  user-select: none;
}
.nav-dropdown:hover .dropbtn {
  color: #fff;
  border-bottom-color: var(--accent);
}
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  padding: 6px 0;
  z-index: 200;
}
.nav-dropdown:hover .dropdown-content {
  display: block;
}
.dropdown-content a {
  display: block;
  padding: 8px 16px !important;
  color: var(--text) !important;
  font-size: 0.9rem !important;
  text-decoration: none;
  margin-left: 0 !important;
  border-bottom: none !important;
  transition: background 0.15s ease;
}
.dropdown-content a:hover {
  background: var(--bg);
  color: var(--accent) !important;
  border-bottom: none !important;
}

/* ── Login Button ── */
.login-btn {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.login-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ── User Dropdown ── */
.user-dropdown {
  position: relative;
  display: inline-block;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  user-select: none;
}

.user-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.user-caret {
  font-size: 0.7rem;
  opacity: 0.7;
}

.user-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  min-width: 170px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  padding: 6px 0;
  z-index: 200;
}

.user-dropdown:hover .user-dropdown-content {
  display: block;
}

.user-dropdown-content a {
  display: block;
  padding: 9px 16px;
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.user-dropdown-content a:hover {
  background: var(--bg);
  color: var(--accent);
}

/* ── Dark Mode ── */
[data-theme="dark"] {
  --primary: #1a1a2e;
  --primary-light: #16213e;
  --accent: #4da6ff;
  --accent-hover: #3d8bd9;
  --danger: #e74c3c;
  --danger-hover: #c0392b;
  --success: #27ae60;
  --bg: #0f0f23;
  --card-bg: #1a1a2e;
  --text: #e0e0e0;
  --text-light: #a0a0b0;
  --border: #2a2a4a;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .navbar {
  background: #0d0d1a;
}
[data-theme="dark"] .footer {
  background: #0d0d1a;
  border-top-color: var(--border);
}
[data-theme="dark"] .dropdown-content {
  background: var(--card-bg);
}
[data-theme="dark"] .dropdown-content a:hover {
  background: var(--primary-light);
}

[data-theme="dark"] .user-dropdown-content {
  background: var(--card-bg);
}

[data-theme="dark"] .user-dropdown-content a:hover {
  background: var(--primary-light);
}

[data-theme="dark"] .dropdown-divider {
  background: var(--border);
}

[data-theme="dark"] .login-btn {
  color: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] .login-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--primary);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .post-card {
  background: var(--card-bg);
}
[data-theme="dark"] .post-card .post-excerpt {
  color: #b0b0c0;
}
[data-theme="dark"] .tag-badge,
[data-theme="dark"] .tag-link {
  background: var(--primary-light);
  color: var(--accent);
}
[data-theme="dark"] .tag-link:hover,
[data-theme="dark"] .tag-badge:hover {
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .admin-table tbody tr:nth-child(even) {
  background: #12122a;
}
[data-theme="dark"] .admin-table tbody tr:hover {
  background: #1e1e3a;
}
[data-theme="dark"] .error {
  background: #3d1a1a;
  border-color: #5a2a2a;
}
[data-theme="dark"] .preview-label {
  background: #12122a;
}
[data-theme="dark"] .preview-content code {
  background: #2a2a4a;
}
[data-theme="dark"] .preview-content pre {
  background: #12122a;
}
[data-theme="dark"] .comment {
  border-bottom-color: var(--border);
}
[data-theme="dark"] .comment-success {
  background: #1a3d1a;
  color: #6fcf6f;
}
[data-theme="dark"] .search-input {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
[data-theme="dark"] .search-input:focus {
  background: rgba(255,255,255,0.12);
}
[data-theme="dark"] .search-input::placeholder {
  color: rgba(255,255,255,0.4);
}
[data-theme="dark"] .date-badge {
  background: var(--primary-light);
}
[data-theme="dark"] .article-card .post-content {
  color: #c0c0d0;
}
[data-theme="dark"] .nav-link-row input[type="text"] {
  background: var(--primary);
  color: var(--text);
}
[data-theme="dark"] .tag-filter-info {
  background: #12122a;
}
[data-theme="dark"] .clear-filter:hover {
  color: var(--danger);
}

/* ── User Role Badges ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.8rem;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-admin {
  background: #e8f5e9;
  color: #2e7d32;
}
.badge-editor {
  background: #e3f2fd;
  color: #1565c0;
}
[data-theme="dark"] .badge-admin {
  background: #1a3d1a;
  color: #6fcf6f;
}
[data-theme="dark"] .badge-editor {
  background: #1a2a3d;
  color: #6fb5e8;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.text-muted {
  color: var(--text-light);
  font-style: italic;
  font-size: 0.85rem;
}

/* ── Archives ── */
.archive-list {
  list-style: none;
  padding: 0;
  margin-bottom: 1.5rem;
}
.archive-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 1rem;
}
.archive-list li:last-child {
  border-bottom: none;
}
.archive-date {
  font-size: 0.85rem;
  color: var(--text-light);
  min-width: 3.5rem;
  flex-shrink: 0;
}

[data-theme="dark"] .archive-list li {
  border-bottom-color: var(--border);
}

/* ── Related / Popular Posts ── */
.related-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.related-section h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}
.related-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.related-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.related-item:hover {
  box-shadow: var(--shadow-hover);
}
.related-item a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.related-item a:hover {
  color: var(--accent);
}
.related-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  white-space: nowrap;
  margin-left: 0.75rem;
}

@media (max-width: 480px) {
  .related-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

[data-theme="dark"] .related-item {
  background: var(--card-bg);
}

/* ── Dashboard Stats ── */
.stats-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.stats-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--accent);
}
.stat-card.stat-published {
  border-left-color: var(--success);
}
.stat-card.stat-draft {
  border-left-color: #e67e22;
}
.stat-card.stat-views {
  border-left-color: #9b59b6;
}
.stat-card.stat-comments {
  border-left-color: #1abc9c;
}
.stat-card.stat-tags {
  border-left-color: #f39c12;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chart-wrapper {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  height: 250px;
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .stat-card {
    padding: 0.75rem;
  }
  .stat-value {
    font-size: 1.3rem;
  }
}
