/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-primary: #14141c;
  --bg-secondary: #1b1b2f;
  --bg-tertiary: #252540;
  --accent-green: #1bb76e;
  --accent-green-hover: #15995d;
  --accent-red: #e74c3c;
  --accent-red-hover: #c0392b;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b8;
  --text-muted: #6c6c85;
  --border-color: #2a2a45;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.logo-icon { font-size: 28px; }
.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-green);
}
.search-bar {
  flex: 1;
  display: flex;
  max-width: 500px;
}
.search-bar input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.search-bar input:focus { border-color: var(--accent-green); }
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar button {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  font-size: 14px;
}
.btn-new-post {
  padding: 10px 20px;
  background: var(--accent-green);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}
.btn-new-post:hover { background: var(--accent-green-hover); }
.filter-bar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.filter-tabs { display: flex; gap: 8px; }
.filter-tab {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.filter-tab:hover {
  border-color: var(--accent-green);
  color: var(--text-primary);
}
.filter-tab.active {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}
.post-count {
  color: var(--text-muted);
  font-size: 13px;
}
.gallery-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 48px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.post-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--border-color);
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.post-card-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--bg-tertiary);
}
.post-card-body { padding: 12px 16px; }
.post-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.post-card-stats .upvotes {
  color: var(--accent-green);
  font-weight: 600;
}
.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.tag-pill {
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-muted);
}
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}
.modal-large { max-width: 960px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition);
}
.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.modal-body { padding: 24px; }
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  margin-bottom: 24px;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-green);
  background: rgba(27, 183, 110, 0.05);
}
.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.upload-prompt p {
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.upload-hint {
  font-size: 13px;
  color: var(--text-muted);
}
.upload-formats {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.upload-preview {
  position: relative;
  display: inline-block;
}
.upload-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius);
}
.btn-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 14px;
}
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus { border-color: var(--accent-green); }
.form-group input::placeholder { color: var(--text-muted); }
.btn-submit {
  width: 100%;
  padding: 12px;
  background: var(--accent-green);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-submit:hover { background: var(--accent-green-hover); }
.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.error-message {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.post-detail-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  margin-bottom: 24px;
}
.post-image-container img {
  width: 100%;
  border-radius: var(--radius);
  cursor: zoom-in;
}
.vote-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.vote-btn {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: all var(--transition);
}
.vote-btn:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
}
.vote-btn.active-up {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}
.vote-btn.active-down {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
}
.vote-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-green);
}
.post-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.post-tags .tag-pill {
  padding: 4px 10px;
  font-size: 12px;
}
.post-author {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.post-author strong { color: var(--accent-green); }
.post-date {
  font-size: 12px;
  color: var(--text-muted);
}
.comments-section {
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
}
.comments-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
}
.comment-form {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.comment-form input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.comment-form input:focus { border-color: var(--accent-green); }
.btn-comment {
  padding: 10px 20px;
  background: var(--accent-green);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-comment:hover { background: var(--accent-green-hover); }
.comment-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}
.comment-item:last-child { border-bottom: none; }
.comment-item.reply {
  margin-left: 32px;
  border-left: 2px solid var(--border-color);
  padding-left: 16px;
}
.comment-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-green);
  margin-bottom: 4px;
}
.comment-text {
  font-size: 14px;
  color: var(--text-secondary);
}
.comment-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.fullscreen-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.fullscreen-overlay.active { display: flex; }
.fullscreen-overlay img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}
.toast.success {
  border-color: var(--accent-green);
  color: var(--accent-green);
}
.toast.error {
  border-color: var(--accent-red);
  color: var(--accent-red);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@media (max-width: 1024px) {
  .post-detail-grid { grid-template-columns: 1fr; }
  .post-sidebar { order: -1; }
}
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }
  .search-bar {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
  .filter-bar { padding: 12px 16px; }
  .filter-tabs {
    overflow-x: auto;
    gap: 6px;
  }
  .filter-tab {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
  }
  .gallery-container { padding: 0 16px 32px; }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
  }
  .modal { max-width: 100%; margin: 16px; }
  .modal-large { max-width: 100%; }
}
@media (max-width: 375px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .logo-text { display: none; }
  .btn-new-post {
    padding: 8px 14px;
    font-size: 13px;
  }
}