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

:root {
  --green: #3B6D11;
  --green-light: #EAF3DE;
  --green-mid: #639922;
  --green-text: #27500A;
  --bg: #f5f5f0;
  --surface: #ffffff;
  --border: #e2e2dc;
  --text: #1a1a18;
  --text-muted: #6b6b66;
  --text-faint: #a0a09a;
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1c1c1a;
    --border: #2e2e2a;
    --text: #e8e8e2;
    --text-muted: #9a9a94;
    --text-faint: #5a5a56;
    --green-light: #1a2e0a;
    --green-text: #97C459;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* OVERLAY / MODAL */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%; max-width: 380px;
  border: 1px solid var(--border);
}
.modal-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.modal-title { text-align: center; font-size: 22px; font-weight: 600; color: var(--text); }
.modal-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 1.5rem; }

.auth-tabs { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 1.25rem; }
.auth-tab { flex: 1; padding: 8px; background: transparent; border: none; cursor: pointer; font-size: 14px; color: var(--text-muted); transition: background 0.15s; }
.auth-tab.active { background: var(--green); color: #fff; font-weight: 500; }

.input-field {
  display: block; width: 100%;
  padding: 10px 12px; margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-size: 15px; outline: none;
  transition: border-color 0.15s;
}
.input-field:focus { border-color: var(--green); }

.btn-primary {
  display: block; width: 100%;
  padding: 10px;
  background: var(--green); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500;
  cursor: pointer; margin-top: 4px;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }

.auth-error {
  background: #fee; color: #c00;
  border: 1px solid #fcc;
  border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px;
  margin-bottom: 12px;
}

/* LAYOUT */
#app {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  gap: 0;
}
#app.hidden { display: none; }

/* SIDEBAR */
.sidebar {
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 600;
  color: var(--text); margin-bottom: 2rem;
  padding: 0 8px;
}
.logo-icon { font-size: 24px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text-muted);
  font-size: 15px; font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--green-light); color: var(--green-text); }
.nav-item.active { background: var(--green-light); color: var(--green-text); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-top: 1px solid var(--border);
  margin-top: auto;
}
.sidebar-username { font-size: 13px; font-weight: 500; color: var(--text); display: block; }
.logout-link { font-size: 12px; color: var(--text-faint); text-decoration: none; }
.logout-link:hover { color: #c00; }
.sidebar-user-info { display: flex; flex-direction: column; }

/* AVATAR */
.avatar-circle {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  flex-shrink: 0; text-transform: uppercase;
}
.avatar-circle.sm { width: 32px; height: 32px; font-size: 12px; }

/* FEED */
.feed {
  border-right: 1px solid var(--border);
  min-height: 100vh;
}

.feed-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 10;
}
.feed-header h2 { font-size: 18px; font-weight: 600; }

.online-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted);
}
.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4caf50;
}

/* COMPOSE */
.compose-box {
  display: flex; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.compose-avatar { flex-shrink: 0; }
.compose-inner { flex: 1; }

#compose-text {
  width: 100%; border: none; outline: none;
  background: transparent; color: var(--text);
  font-size: 16px; resize: none;
  font-family: inherit; line-height: 1.5;
  margin-bottom: 10px;
}
#compose-text::placeholder { color: var(--text-faint); }

.compose-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.compose-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tag-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent; color: var(--text-muted);
  font-size: 12px; cursor: pointer;
  transition: all 0.12s;
}
.tag-btn:hover { border-color: var(--green); color: var(--green); }
.tag-btn.selected { background: var(--green-light); border-color: var(--green); color: var(--green-text); }

.compose-right { display: flex; align-items: center; gap: 10px; }
#char-count { font-size: 13px; color: var(--text-faint); }
#char-count.warn { color: #e07000; }
#char-count.over { color: #c00; }

.btn-post {
  padding: 7px 18px;
  background: var(--green); color: #fff;
  border: none; border-radius: 20px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: opacity 0.15s;
}
.btn-post:hover { opacity: 0.88; }
.btn-post:disabled { opacity: 0.4; cursor: not-allowed; }

.selected-tag {
  margin-top: 8px; font-size: 13px; color: var(--green-text);
  background: var(--green-light); border-radius: 6px;
  padding: 4px 10px; display: inline-block;
}

/* POST CARD */
.post-card {
  display: flex; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.1s;
}
.post-card:hover { background: var(--bg); }

.post-body { flex: 1; min-width: 0; }
.post-meta {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px; flex-wrap: wrap;
}
.post-username { font-weight: 600; font-size: 14px; color: var(--text); }
.post-handle { font-size: 13px; color: var(--text-faint); }
.post-time { font-size: 12px; color: var(--text-faint); }

.post-category {
  display: inline-block;
  background: var(--green-light); color: var(--green-text);
  font-size: 11px; padding: 2px 8px;
  border-radius: 10px; margin-bottom: 6px;
}

.post-text { font-size: 14px; color: var(--text); line-height: 1.55; word-break: break-word; }

.post-actions {
  display: flex; gap: 20px; margin-top: 10px;
}
.post-action {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-faint);
  background: none; border: none; cursor: pointer;
  padding: 0; transition: color 0.12s;
}
.post-action:hover { color: var(--green); }
.post-action.liked { color: #e0406a; }
.post-action svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.post-action.liked svg.heart { fill: #e0406a; stroke: #e0406a; }

.post-delete {
  margin-left: auto;
  font-size: 13px; color: var(--text-faint);
  background: none; border: none; cursor: pointer;
}
.post-delete:hover { color: #c00; }

/* RIGHT PANEL */
.right-panel { padding: 1.5rem 1rem; }
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.panel-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.panel-text { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.panel-text code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.server-stat {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text-muted);
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.server-stat:last-child { border: none; }
.stat-val { font-weight: 500; color: var(--text); }

.rules-list { list-style: none; }
.rules-list li { font-size: 13px; color: var(--text-muted); padding: 4px 0; }
.rules-list li::before { content: "•  "; color: var(--green); }

/* ADMIN BADGE */
.admin-badge {
  display: inline-block;
  background: #FFF3CD; color: #856404;
  font-size: 11px; padding: 1px 7px;
  border-radius: 10px; border: 1px solid #FFDC7A;
  font-weight: 500;
}

/* SIDEBAR ROLE */
.sidebar-role {
  font-size: 11px; color: #856404;
  background: #FFF3CD; border: 1px solid #FFDC7A;
  border-radius: 8px; padding: 1px 6px;
  display: none; margin-bottom: 2px;
}

/* EVENTS LOCKED */
.events-locked {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px; color: var(--text-muted);
}
.events-locked span { font-size: 24px; }

/* DISCLAIMER */
.modal-disclaimer {
  margin-top: 1.25rem;
  font-size: 11px; color: var(--text-faint);
  text-align: center; line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.disclaimer-card { border: 1px solid #e0c070 !important; background: #fffbea !important; }
.disclaimer-text { font-size: 12px; color: #856404; line-height: 1.5; }

/* STATES */
.loading { padding: 2rem; text-align: center; color: var(--text-muted); font-size: 14px; }
.empty-state { padding: 3rem 2rem; text-align: center; color: var(--text-faint); font-size: 15px; }
.empty-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.hidden { display: none !important; }

/* RESPONSIVE */
@media (max-width: 900px) {
  #app { grid-template-columns: 60px 1fr; }
  .right-panel { display: none; }
  .logo-text, .nav-item span:last-child, .sidebar-user-info { display: none; }
  .sidebar { padding: 1rem 0.5rem; align-items: center; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar-user { justify-content: center; }
}
@media (max-width: 600px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* AD SLOTS */
.ad-slot {
  border-radius: var(--radius);
  border: 2px dashed #a0b88a;
  margin-bottom: 1rem;
  overflow: hidden;
  position: relative;
  background: repeating-linear-gradient(
    -45deg,
    #f0f5eb,
    #f0f5eb 6px,
    #e6eed9 6px,
    #e6eed9 12px
  );
}
.ad-slot-inner {
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
  margin: 8px;
  overflow: hidden;
}
.ad-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #6a8a45;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 7px 12px 5px;
  border-bottom: 1px dashed #b8d090;
}
.ad-label::before { content: "AD"; font-size: 9px; background: #b8d090; color: #3a5a1a; padding: 1px 4px; border-radius: 3px; }
.ad-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  gap: 6px;
  text-align: center;
}
.ad-slot-banner .ad-placeholder { min-height: 110px; }
.ad-slot-mid .ad-placeholder    { min-height: 80px; }
.ad-slot-bottom .ad-placeholder { min-height: 80px; }
.ad-placeholder-icon { font-size: 28px; opacity: 0.55; }
.ad-placeholder-text { font-size: 13px; font-weight: 700; color: #4a6a2a; }
.ad-placeholder-sub  { font-size: 11px; color: #7a9a55; line-height: 1.4; }
.ad-placeholder-size {
  display: inline-block; margin-top: 4px;
  font-size: 10px; background: #d0e8b0; color: #3a5a1a;
  border-radius: 4px; padding: 2px 8px;
  font-weight: 600; letter-spacing: 0.04em;
}
.ad-slot a { display: block; }
.ad-slot img { display: block; width: 100%; border-radius: 8px; }

/* ── PROFILE VIEW ─────────────────────────────────────── */

#view-profile { display: block; }

.btn-back {
  background: none; border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 14px;
  font-size: 14px; cursor: pointer;
  color: var(--text); transition: background 0.12s;
}
.btn-back:hover { background: var(--bg); }

.profile-banner {
  height: 100px;
  background: linear-gradient(135deg, #3B6D11 0%, #639922 60%, #9DC45A 100%);
}

.profile-top {
  display: flex; align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px 12px;
  margin-top: -36px;
}

.profile-avatar-wrap { position: relative; display: inline-block; }

.avatar-xl {
  width: 80px !important; height: 80px !important;
  font-size: 26px !important;
  border: 4px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.avatar-upload-btn {
  position: absolute; bottom: 0; right: -2px;
  background: var(--green); color: #fff;
  border-radius: 50%; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer;
  border: 2px solid var(--surface);
}

.profile-actions { display: flex; gap: 8px; padding-bottom: 4px; }

.btn-follow {
  padding: 7px 18px;
  background: var(--green); color: #fff;
  border: none; border-radius: 20px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: opacity 0.15s;
}
.btn-follow:hover { opacity: 0.85; }
.btn-follow.following {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-follow.following:hover { border-color: #c00; color: #c00; }

.btn-outline {
  padding: 7px 18px;
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background 0.12s;
}
.btn-outline:hover { background: var(--bg); }

.profile-info { padding: 4px 20px 16px; border-bottom: 1px solid var(--border); }
.profile-name { font-size: 20px; font-weight: 700; color: var(--text); }
.profile-handle { font-size: 14px; color: var(--text-faint); margin-bottom: 6px; }
.profile-bio { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.profile-stats {
  display: flex; gap: 16px;
  font-size: 14px; color: var(--text-muted);
}
.profile-stats span { font-weight: 500; color: var(--text); }

.edit-profile-form {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex; gap: 8px; align-items: center;
}
.edit-profile-form .input-field { margin: 0; flex: 1; }
.edit-profile-form .btn-primary { width: auto; margin: 0; padding: 10px 16px; white-space: nowrap; }

/* Clickable username in posts */
.post-username:hover { text-decoration: underline; }
