/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  line-height: 1.7;
  direction: rtl;
  min-height: 100vh;
}

a { color: #64b5f6; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Skip to Content (a11y) === */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: #e94560;
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 200;
}
.skip-link:focus { top: 0; }

/* === Header === */
.site-header {
  background: #16213e;
  border-bottom: 2px solid #0f3460;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  gap: 0.75rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: #e94560;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; color: #ff6b6b; }

/* Search */
.search-form {
  display: flex;
  align-items: center;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 20px;
  overflow: hidden;
  flex: 1;
  max-width: 400px;
}
.search-input {
  background: transparent;
  border: none;
  color: #e0e0e0;
  padding: 0.4rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
  width: 100%;
  direction: rtl;
}
.search-input:focus { outline: none; }
.search-input::placeholder { color: #666; }
.search-btn {
  background: none;
  border: none;
  color: #888;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.search-btn:hover { color: #e94560; }

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.4rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-link {
  color: #b0b0b0;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  transition: background 0.2s;
  white-space: nowrap;
  font-size: 0.9rem;
}
.nav-link:hover { background: rgba(255,255,255,0.05); text-decoration: none; color: #fff; }

.nav-user { color: #64b5f6; font-weight: 600; }

.logout-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-register { background: #e94560; color: #fff !important; font-weight: 600; }
.btn-register:hover { background: #ff6b6b; }

/* Notification badge */
.notification-link { position: relative; }
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e94560;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* === Container === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* === Home Layout === */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}

/* home-layout responsive: see consolidated mobile block */

/* === Landing Hero === */
.landing-hero {
  background: linear-gradient(135deg, #16213e, #0f3460);
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.landing-hero h1 { font-size: 1.8rem; color: #fff; margin-bottom: 0.5rem; }
.landing-hero p { color: #aaa; font-size: 1rem; margin-bottom: 1.5rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* === Sidebar === */
.sidebar-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 1rem;
}
.sidebar-title {
  font-size: 1rem;
  color: #e94560;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #0f3460;
}
.sidebar-more-link {
  display: block;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  color: #888;
  margin-top: 0.5rem;
}
.sidebar-more-link:hover { color: #64b5f6; text-decoration: none; }

.community-list { list-style: none; }
.community-list li a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  color: #e0e0e0;
  transition: background 0.2s;
}
.community-list li a:hover { background: rgba(255,255,255,0.05); text-decoration: none; }
.community-icon { font-size: 1.2rem; }
.community-name { flex: 1; font-weight: 600; }
.follower-count { font-size: 0.8rem; color: #888; }

/* === Section Title === */
.section-title { font-size: 1.1rem; color: #b0b0b0; margin-bottom: 1rem; }

/* === Post Card === */
.post-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  display: flex;
  transition: border-color 0.2s;
}
.post-card:hover { border-color: #1a5276; }
.post-card.compact { padding: 0.75rem; display: block; }

.vote-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.5rem;
  min-width: 50px;
  background: rgba(0,0,0,0.15);
  border-radius: 8px 0 0 8px;
}
[dir="rtl"] .vote-controls { border-radius: 0 8px 8px 0; }

.vote-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}
.vote-btn:hover { background: rgba(255,255,255,0.05); }
.vote-btn:focus-visible { outline: 2px solid #e94560; outline-offset: 2px; }
.vote-btn.upvote.active { color: #e94560; }
.vote-btn.downvote.active { color: #64b5f6; }

.score { font-weight: 700; font-size: 0.9rem; margin: 2px 0; color: #ccc; transition: opacity 0.2s; }

.post-content { padding: 0.75rem 1rem; flex: 1; min-width: 0; }

.post-meta {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.community-tag {
  background: #0f3460;
  color: #64b5f6;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.community-tag:hover { text-decoration: none; background: #1a5276; }

.post-author { color: #aaa; }
.separator { color: #555; }

.edited-badge { color: #888; font-size: 0.75rem; font-style: italic; }

.post-title { font-size: 1.05rem; font-weight: 600; color: #e0e0e0; display: block; margin-bottom: 0.3rem; }
.post-title:hover { color: #fff; text-decoration: none; }

.post-body-preview { color: #999; font-size: 0.85rem; margin-bottom: 0.5rem; }

.post-media { margin: 0.5rem 0; max-height: 300px; overflow: hidden; border-radius: 6px; }
.post-media img, .post-media video { max-width: 100%; max-height: 300px; object-fit: cover; border-radius: 6px; }

.post-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; flex-wrap: wrap; }

.action-link, .share-btn {
  font-size: 0.8rem;
  color: #888;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.action-link:hover, .share-btn:hover { background: rgba(255,255,255,0.05); text-decoration: none; color: #bbb; }

.post-stats { display: flex; gap: 1rem; font-size: 0.8rem; color: #888; margin-top: 0.3rem; }

/* === Post Full View === */
.post-full {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  display: flex;
  margin-bottom: 1.5rem;
}
.post-title-full { font-size: 1.4rem; margin-bottom: 0.75rem; color: #fff; }
.post-body-full { color: #ccc; font-size: 0.95rem; line-height: 1.8; margin-bottom: 1rem; }
.post-media-full img, .post-media-full video { max-width: 100%; max-height: 600px; border-radius: 8px; }

/* === Community Header === */
.community-header-banner {
  background: linear-gradient(135deg, #16213e, #0f3460);
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.community-info { display: flex; align-items: center; gap: 1rem; }
.community-big-icon { font-size: 3rem; }
.community-desc { color: #aaa; font-size: 0.9rem; }
.follower-badge { background: rgba(255,255,255,0.1); padding: 2px 10px; border-radius: 12px; font-size: 0.8rem; color: #aaa; }
.community-actions { display: flex; gap: 0.5rem; align-items: center; }

/* === Sort Bar === */
.sort-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  flex-wrap: wrap;
}
.sort-option { padding: 0.4rem 1rem; border-radius: 20px; color: #888; font-size: 0.85rem; transition: all 0.2s; }
.sort-option:hover { text-decoration: none; color: #ccc; background: rgba(255,255,255,0.05); }
.sort-option.active { background: #e94560; color: #fff; }

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 0;
}
.pagination-link {
  background: #16213e;
  border: 1px solid #0f3460;
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  color: #64b5f6;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.pagination-link:hover { background: #0f3460; text-decoration: none; }
.pagination-info { color: #888; font-size: 0.85rem; }

/* === Comments === */
.comments-section {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 1.5rem;
}
.comments-title {
  font-size: 1rem;
  color: #b0b0b0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #0f3460;
}
.comment-form { margin-bottom: 1.5rem; }
.comment-form textarea, .reply-form textarea, .edit-comment-textarea {
  width: 100%;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 0.75rem;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 0.5rem;
}
.comment-form textarea:focus, .reply-form textarea:focus, .edit-comment-textarea:focus {
  outline: none;
  border-color: #e94560;
}

.comment {
  border-right: 3px solid #0f3460;
  padding-right: 1rem;
  margin-bottom: 1rem;
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}
.comment-vote { display: flex; align-items: center; gap: 0.25rem; }
.comment-vote .vote-btn { font-size: 0.75rem; padding: 1px 4px; }
.comment-vote .score { font-size: 0.8rem; }
.comment-author { font-weight: 600; color: #64b5f6; }
.comment-time { color: #666; font-size: 0.75rem; }
.comment-body { color: #ccc; font-size: 0.9rem; line-height: 1.7; white-space: pre-wrap; }
.comment-actions { margin-top: 0.3rem; }
.reply-toggle {
  background: none;
  border: none;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.reply-toggle:hover { background: rgba(255,255,255,0.05); color: #bbb; }
.reply-form { margin-top: 0.5rem; }
.comment-children { margin-top: 0.75rem; padding-right: 1rem; }
.login-prompt { color: #888; font-size: 0.9rem; margin-bottom: 1rem; }

/* === Auth Card === */
.auth-card {
  max-width: 420px;
  margin: 2rem auto;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 2rem;
}
.auth-card h1 { font-size: 1.3rem; margin-bottom: 1.5rem; color: #fff; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: #aaa; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.9rem;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: #e94560; }
.form-group input[type="file"] { padding: 0.5rem; }

.char-counter { font-size: 0.75rem; color: #666; text-align: left; margin-top: 0.25rem; direction: ltr; }

.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: #888; }

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid #64b5f6; outline-offset: 2px; }

.btn-primary { background: #e94560; color: #fff; }
.btn-primary:hover { background: #ff6b6b; color: #fff; }
.btn-outline { background: transparent; border: 1px solid #e94560; color: #e94560; }
.btn-outline:hover { background: #e94560; color: #fff; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; }

/* === Alert === */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: rgba(233, 69, 96, 0.15); border: 1px solid rgba(233, 69, 96, 0.3); color: #ff6b6b; }
.alert-success { background: rgba(76, 175, 80, 0.15); border: 1px solid rgba(76, 175, 80, 0.3); color: #81c784; }

/* === Toast === */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
.toast {
  background: #16213e;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: rgba(76, 175, 80, 0.3); }
.toast-error { border-color: rgba(233, 69, 96, 0.3); color: #ff6b6b; }

/* === Modal === */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
}
.modal-content {
  position: relative;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 450px;
  width: 90%;
}
.modal-content h3 { color: #fff; margin-bottom: 1rem; font-size: 1.1rem; }
.modal-content textarea {
  width: 100%;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 0.75rem;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}
.modal-content textarea:focus { outline: none; border-color: #e94560; }

/* === Profile === */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, #16213e, #0f3460);
  border-radius: 12px;
  padding: 2rem;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  background: #e94560;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.profile-avatar-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.profile-info h1 { font-size: 1.4rem; color: #fff; }
.profile-date { font-size: 0.85rem; color: #888; }

.karma-display { display: flex; gap: 1rem; margin-top: 0.5rem; flex-wrap: wrap; }
.karma-item {
  background: rgba(255,255,255,0.05);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  color: #aaa;
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; margin-right: 0.5rem; }
.badge-verified { background: rgba(100, 181, 246, 0.15); color: #64b5f6; }

.profile-content {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
/* profile-content responsive: see consolidated mobile block */

.comment-preview {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}
.comment-on { font-size: 0.8rem; color: #888; display: block; margin-bottom: 0.3rem; }
.comment-preview p { color: #ccc; font-size: 0.9rem; }

/* === Create Post === */
.create-post-card {
  max-width: 700px;
  margin: 1rem auto;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 2rem;
}
.create-post-card h1 { font-size: 1.2rem; margin-bottom: 1.5rem; color: #fff; }

.file-preview { margin-top: 0.5rem; }

/* === Search Page === */
.search-page-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.search-page-input {
  flex: 1;
  padding: 0.65rem 1rem;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.95rem;
  direction: rtl;
}
.search-page-input:focus { outline: none; border-color: #e94560; }

/* === Notifications === */
.notifications-list { display: flex; flex-direction: column; gap: 0.5rem; }
.notification-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  color: #e0e0e0;
  transition: background 0.2s;
}
.notification-item:hover { background: #1a2540; text-decoration: none; }
.notification-item.unread { border-right: 3px solid #e94560; }
.notification-icon { font-size: 1.3rem; }
.notification-content p { font-size: 0.9rem; margin-bottom: 0.25rem; }
.notification-time { font-size: 0.75rem; color: #666; }

/* === Error Page === */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 5rem; color: #e94560; margin-bottom: 0.5rem; }
.error-page p { font-size: 1.1rem; color: #888; margin-bottom: 1.5rem; }

/* === Empty State === */
.empty-state { color: #666; text-align: center; padding: 2rem; font-size: 0.9rem; }

/* === Community Grid === */
.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.community-grid-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  transition: border-color 0.2s, transform 0.2s;
  color: #e0e0e0;
}
.community-grid-card:hover { border-color: #e94560; transform: translateY(-2px); text-decoration: none; }
.community-grid-icon { font-size: 2.5rem; }
.community-grid-name { font-weight: 700; font-size: 1rem; color: #fff; }
.community-grid-desc { font-size: 0.8rem; color: #999; line-height: 1.5; }
.community-grid-followers {
  font-size: 0.75rem;
  color: #888;
  background: rgba(255,255,255,0.05);
  padding: 2px 10px;
  border-radius: 12px;
}

@media (max-width: 480px) {
  .community-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* === Embed Styles === */
.embed-container { margin: 1rem 0; max-width: 100%; }
.embed-youtube { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 8px; }
.embed-youtube iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 8px; }
.embed-twitter { max-width: 550px; }
.embed-facebook { max-width: 550px; }

/* === Community Layout === */
.community-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
.community-feed { min-width: 0; }

/* community-layout responsive: see consolidated mobile block */

/* === Admin Delete Button === */
.admin-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: #ff6b6b;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}
.admin-delete-btn:hover { background: rgba(233, 69, 96, 0.15); text-decoration: none; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #1a5276; }

/* === Thread Toggle === */
.thread-toggle {
  background: none;
  border: none;
  color: #64b5f6;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-top: 0.25rem;
  display: inline-block;
}
.thread-toggle:hover { background: rgba(100, 181, 246, 0.1); text-decoration: underline; }
.comment-children.collapsed { display: none; }

/* === Signup Stepper === */
.signup-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  direction: ltr;
}
.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0f3460;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.3s;
  flex-shrink: 0;
}
.step-dot.active { background: #e94560; color: #fff; }
.step-dot.done { background: #4caf50; color: #fff; }
.step-line {
  height: 2px;
  width: 60px;
  background: #0f3460;
  transition: background 0.3s;
}
.step-line.active { background: #e94560; }
.step-line.done { background: #4caf50; }
.step-description {
  text-align: center;
  color: #888;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}
.step-content { display: none; }
.step-content.active { display: block; }
.step-back {
  background: none;
  border: none;
  color: #888;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  margin-top: 0.5rem;
}
.step-back:hover { color: #bbb; background: rgba(255,255,255,0.05); }
.form-hint {
  font-size: 0.78rem;
  color: #666;
  margin-top: 0.25rem;
}
.verification-code-input {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  direction: ltr;
  margin: 1.5rem 0;
}
.verification-code-input input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  color: #e0e0e0;
  font-family: inherit;
}
.verification-code-input input:focus { outline: none; border-color: #e94560; }
.btn-skip {
  background: transparent;
  border: 1px solid #333;
  color: #888;
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-skip:hover { border-color: #555; color: #bbb; }
.step-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* === Post Type Tabs === */
.post-type-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid #0f3460;
  border-radius: 8px;
  overflow: hidden;
}
.post-type-tab {
  flex: 1;
  padding: 0.6rem;
  background: transparent;
  border: none;
  color: #888;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.post-type-tab:not(:last-child) { border-left: 1px solid #0f3460; }
.post-type-tab:hover { background: rgba(255,255,255,0.03); color: #ccc; }
.post-type-tab.active { background: #e94560; color: #fff; }

/* === Focus Indicators (a11y) === */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid #64b5f6;
  outline-offset: 2px;
}

/* ============================= */
/* === Mobile Optimizations  === */
/* ============================= */
@media (max-width: 768px) {
  /* Body & Container */
  body { line-height: 1.5; font-size: 14px; }
  .container { padding: 0.75rem 0.5rem; }

  /* Header */
  .header-inner { height: 48px; gap: 0.5rem; }
  .logo { font-size: 1.2rem; }
  .mobile-menu-btn { display: block; }
  .search-form { flex: 1; max-width: none; }
  .nav-link { font-size: 0.8rem; padding: 0.3rem 0.6rem; }
  .header-nav {
    display: none;
    position: absolute;
    top: 48px;
    right: 0;
    left: 0;
    background: #16213e;
    flex-direction: column;
    padding: 1rem;
    border-bottom: 2px solid #0f3460;
    gap: 0.5rem;
  }
  .header-nav.open { display: flex; }
  .header-nav a, .header-nav button { width: 100%; text-align: right; }

  /* Grid layouts → single column */
  .home-layout { grid-template-columns: 1fr; }
  .sidebar { order: 1; }
  .profile-content { grid-template-columns: 1fr; }
  .community-layout { grid-template-columns: 1fr; }
  .community-layout .sidebar { order: 1; }

  /* Hero */
  .landing-hero { padding: 1.25rem; margin-bottom: 1rem; }
  .landing-hero h1 { font-size: 1.2rem; }
  .landing-hero p { font-size: 0.85rem; margin-bottom: 1rem; }

  /* Post cards — column layout with vote bar at bottom */
  .post-card { flex-direction: column; }
  .vote-controls {
    flex-direction: row;
    min-width: unset;
    padding: 0.4rem 0.75rem;
    border-radius: 0 0 8px 8px;
    gap: 0.5rem;
    order: 2;
  }
  [dir="rtl"] .vote-controls { border-radius: 0 0 8px 8px; }
  .post-content { padding: 0.6rem 0.75rem; order: 1; }
  .post-title { font-size: 0.95rem; }
  .post-meta { font-size: 0.75rem; gap: 0.3rem; }
  .post-body-preview { font-size: 0.8rem; }
  .post-actions { gap: 0.5rem; margin-top: 0.35rem; }
  .action-link, .share-btn { font-size: 0.75rem; padding: 0.6rem 0.5rem; }
  .vote-btn { min-height: 44px; min-width: 36px; }
  .post-media { max-height: 300px; }
  .post-media img, .post-media video { max-height: 300px; }

  /* Full post page — column layout */
  .post-full { flex-direction: column; }
  .post-full .vote-controls {
    flex-direction: row;
    min-width: unset;
    padding: 0.5rem 0.75rem;
    border-radius: 0 0 8px 8px;
    gap: 0.5rem;
    order: 2;
  }
  .post-full .post-content { order: 1; }
  .post-title-full { font-size: 1.15rem; }
  .post-body-full { font-size: 0.85rem; line-height: 1.6; }

  /* Comments */
  .comments-section { padding: 1rem; }
  .comment-children { padding-right: 0.5rem; }
  .comment { padding-right: 0.6rem; }
  .comment-header { gap: 0.4rem; font-size: 0.8rem; }
  .comment-body { font-size: 0.83rem; line-height: 1.5; }
  .comment-vote .vote-btn { font-size: 0.7rem; }
  .comment-vote .score { font-size: 0.75rem; }

  /* Cap nesting depth at 4 levels */
  .comment-children .comment-children .comment-children .comment-children .comment-children {
    padding-right: 0;
  }

  /* Auth card */
  .auth-card { margin: 1rem auto; padding: 1.25rem; }

  /* Sidebar & sort bar */
  .sidebar-card { padding: 0.75rem; }
  .sidebar-title { font-size: 0.9rem; }
  .sort-bar { padding: 0.35rem; gap: 0.35rem; }
  .sort-option { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

  /* Profile */
  .profile-header { padding: 1.25rem; gap: 1rem; }
  .profile-avatar, .profile-avatar-img { width: 60px; height: 60px; }
  .profile-info h1 { font-size: 1.1rem; }

  /* Community header */
  .community-header-banner { padding: 1rem; }
  .community-big-icon { font-size: 2rem; }

  /* Pagination */
  .pagination { gap: 0.5rem; padding: 1rem 0; }
  .pagination-link { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

  /* Signup stepper */
  .step-line { width: 40px; }
  .verification-code-input input { width: 38px; height: 46px; font-size: 1.1rem; }
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
.gallery-thumb {
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  transition: transform 0.2s, box-shadow 0.2s;
}
.gallery-thumb:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.3);
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Gallery Badge on post card */
.post-media { position: relative; }
.gallery-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 10000;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}
.lightbox-close:hover { color: #e94560; }
.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: background 0.2s;
  z-index: 10000;
}
.lightbox-arrow:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-prev { right: 1rem; }
.lightbox-next { left: 1rem; }
.lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.3rem 1rem;
  border-radius: 20px;
}

@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .lightbox-arrow { font-size: 1.8rem; padding: 0.3rem 0.6rem; }
}

@media (max-width: 480px) {
  body { font-size: 13px; }
  .container { padding: 0.5rem 0.35rem; }
  .header-inner { height: 44px; }
  .logo { font-size: 1.1rem; }
  .landing-hero { padding: 1rem; }
  .landing-hero h1 { font-size: 1.05rem; }
  .post-content { padding: 0.5rem 0.6rem; }
  .post-title { font-size: 0.9rem; }
  .comments-section { padding: 0.75rem; }
  .auth-card { margin: 0.5rem auto; padding: 1rem; }
  .profile-header { padding: 1rem; flex-direction: column; text-align: center; }
  .step-line { width: 30px; }
  .step-dot { width: 28px; height: 28px; font-size: 0.75rem; }
  .verification-code-input input { width: 34px; height: 42px; font-size: 1rem; }
}

/* === Markdown Rendered Content === */
.post-body-full p, .comment-body p { margin: 0 0 0.75rem; }
.post-body-full p:last-child, .comment-body p:last-child { margin-bottom: 0; }
.post-body-full a, .comment-body a { color: #64b5f6; text-decoration: underline; }
.post-body-full a:hover, .comment-body a:hover { color: #e94560; }
.post-body-full code, .comment-body code {
  background: #0f3460;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  direction: ltr;
  display: inline-block;
}
.post-body-full pre, .comment-body pre {
  background: #0f3460;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  direction: ltr;
  margin: 0.75rem 0;
}
.post-body-full pre code, .comment-body pre code {
  background: none;
  padding: 0;
}
.post-body-full blockquote, .comment-body blockquote {
  border-right: 4px solid #e94560;
  padding-right: 1rem;
  margin: 0.75rem 0;
  color: #aaa;
}
.post-body-full ul, .post-body-full ol,
.comment-body ul, .comment-body ol {
  padding-right: 1.5rem;
  margin: 0.5rem 0;
}
.post-body-full li, .comment-body li { margin-bottom: 0.25rem; }
.post-body-full h1, .post-body-full h2, .post-body-full h3,
.comment-body h1, .comment-body h2, .comment-body h3 {
  color: #e0e0e0;
  margin: 1rem 0 0.5rem;
  font-weight: 600;
}
.post-body-full strong, .comment-body strong { color: #e0e0e0; }

/* === Button Loading Spinner === */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1em;
  height: 1em;
  margin-top: -0.5em;
  margin-left: -0.5em;
  border: 2px solid currentColor;
  border-color: #fff transparent #fff transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* === Pinned Post Badge === */
.pinned-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  background: rgba(255, 215, 0, 0.08);
  margin-left: 0.25rem;
}

/* === Deleted Comment === */
.comment-deleted-wrapper { opacity: 0.7; }
.comment-deleted {
  color: #666;
  font-style: italic;
  font-size: 0.85rem;
  padding: 0.25rem 0;
}

/* === Bottom Navigation (mobile only) === */
.bottom-nav {
  display: none;
}
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #16213e;
    border-top: 1px solid #0f3460;
    z-index: 90;
    height: 56px;
    justify-content: space-around;
    align-items: stretch;
  }
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #888;
    text-decoration: none;
    font-size: 0.6rem;
    gap: 0.15rem;
    padding: 0.4rem 0;
    transition: color 0.2s;
  }
  .bottom-nav-item:hover { color: #e94560; text-decoration: none; }
  .bottom-nav-icon { font-size: 1.25rem; position: relative; }
  .bottom-nav-label { font-size: 0.6rem; }
  /* Add bottom padding so content is not hidden under the nav */
  body { padding-bottom: 56px; }
}

