:root {
  --bg: #F5F5F7;
  --card: #FFFFFF;
  --primary: #E53935;
  --primary-light: #FFEBEE;
  --primary-hover: #C62828;
  --success: #3DB87A;
  --success-light: #EDFAF3;
  --gold: #F5A623;
  --gold-light: #FFF8EB;
  --danger: #B71C1C;
  --text: #1A1A1A;
  --text-2: #6B7280;
  --text-3: #9CA3AF;
  --border: #E5E7EB;
  --shadow: 0 1px 8px rgba(0,0,0,0.07);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --nav-height: 60px;
  --bottom-nav: 64px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; overflow-x: hidden; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Typography ─────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

.text-secondary { color: var(--text-2); }
.text-small { font-size: 0.8125rem; }
.text-center { text-align: center; }

/* ── Layout ────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.page-layout {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}
.page-layout > * { min-width: 0; }

@media (max-width: 1024px) {
  .page-layout { grid-template-columns: 220px 1fr; }
  .sidebar-right { display: none; }
}
@media (max-width: 720px) {
  .page-layout { grid-template-columns: 1fr; padding: 12px 12px 80px; gap: 0; }
  .sidebar-left { display: none; }
}

/* mobileBanner: only visible on mobile (when sidebar-left is hidden) */
#mobileBanner { display: none; }
@media (max-width: 720px) {
  #mobileBanner { display: block; }
}

/* ── Card ───────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-body { padding: 20px; }
.card-sm { padding: 16px; }

/* ── Button ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(75,126,200,0.35); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #2fa368; }

.btn-outline { background: transparent; color: var(--success); border: 1.5px solid var(--success); }
.btn-outline:hover:not(:disabled) { background: var(--success-light); }

.btn-ghost { background: transparent; color: var(--text-2); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }

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

.btn-block { width: 100%; }

.btn-oauth {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s;
  width: 100%;
}
.btn-oauth:hover { background: var(--bg); border-color: var(--text-3); }
.btn-oauth img, .btn-oauth svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ── Form ───────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--card);
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
}
.form-input:focus { outline: none; border-color: var(--success); box-shadow: 0 0 0 3px rgba(61,184,122,0.15); }
.form-input::placeholder { color: var(--text-3); }

.form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
}
.form-select:focus { outline: none; border-color: var(--success); box-shadow: 0 0 0 3px rgba(61,184,122,0.15); }

.form-hint { font-size: 0.8rem; color: var(--text-2); margin-top: 4px; }
.form-error { font-size: 0.85rem; color: var(--danger); margin-top: 6px; font-weight: 500; }

.input-group { display: flex; gap: 8px; }
.input-group .form-input { flex: 1; }

/* ── Alert ──────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.alert-error { background: #FFF0F0; color: #C62828; border: 1px solid #FFCDD2; }
.alert-success { background: var(--success-light); color: #1D8A55; border: 1px solid #B9EDD4; }
.alert-info { background: #FFF8E1; color: #856404; border: 1px solid #FFE082; }

/* ── Top Navigation ─────────────────────── */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}
.top-nav .container { display: flex; align-items: center; justify-content: space-between; width: 100%; }

.nav-logo {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo span { color: var(--text); }

.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-link:hover { background: var(--success-light); color: var(--success); }
.nav-link.active { background: var(--success-light); color: var(--success); }
.sidebar-left .nav-link.active { background: var(--success-light); color: var(--success); }
.sidebar-left .nav-link:hover { background: var(--success-light); color: var(--success); }

.nav-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--bg); }
.nav-avatar-placeholder {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem; color: var(--primary);
  flex-shrink: 0;
}
/* Reserve avatar space so nav links don't shift when avatar loads */
#navAvatar { width: 36px; height: 36px; flex-shrink: 0; }

@media (max-width: 720px) {
  .nav-links { display: none; }
}

/* ── Bottom Navigation (mobile) ─────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-3);
  font-size: 0.7rem;
  font-weight: 500;
  transition: color 0.15s;
  text-decoration: none;
  border: none;
  background: none;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--primary); }

@media (max-width: 720px) {
  .bottom-nav { display: flex; }
  .rating-breakdown-grid { grid-template-columns: 1fr !important; }
}

/* ── Main content offset ────────────────── */
.main-content { padding-top: calc(var(--nav-height) + 4px); min-height: calc(100vh - var(--nav-height)); }

/* ── Clean Time Banner ──────────────────── */
.clean-banner {
  background: linear-gradient(135deg, #3DB87A 0%, #2FA368 100%);
  color: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.clean-banner h3 { font-size: 0.875rem; opacity: 0.85; font-weight: 500; margin-bottom: 6px; }
.clean-time-counter {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.clean-time-counter small {
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.85;
}
.clean-since-text { font-size: 0.8rem; opacity: 0.75; margin-top: 6px; }
.profile-timer { font-size: 1.75rem; font-weight: 800; color: var(--success); word-break: break-word; line-height: 1.2; }
.profile-clean-since { font-size: 0.85rem; color: var(--text-2); margin-top: 6px; word-break: break-word; }
.clean-addiction { margin-top: 12px; background: rgba(255,255,255,0.18); border-radius: 20px; padding: 5px 12px; display: inline-block; font-size: 0.85rem; font-weight: 500; }

/* ── Post Card ──────────────────────────── */
.post-card { margin-bottom: 12px; }
.post-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.post-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg); }
.post-avatar-placeholder {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: var(--primary);
  flex-shrink: 0;
}
.post-meta { flex: 1; min-width: 0; }
.post-username { font-weight: 600; font-size: 0.9375rem; color: var(--text); }
.post-username a { color: inherit; text-decoration: none; }
.post-username a:hover { color: var(--primary); }
.post-status { font-size: 0.78rem; color: var(--success); font-weight: 500; margin-top: 1px; }
.post-time { font-size: 0.78rem; color: var(--text-3); }
.post-content { font-size: 0.9375rem; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-word; }

/* ── Post Composer ──────────────────────── */
.composer { padding: 16px; margin-bottom: 16px; }
.composer-inner { display: flex; gap: 12px; }
.composer-inner > div:last-child { flex: 1; min-width: 0; }
.composer-input {
  width: 100%;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.18s;
  min-height: 80px;
  box-sizing: border-box;
}
.composer-input:focus { outline: none; border-color: var(--success); box-shadow: 0 0 0 3px rgba(61,184,122,0.15); background: var(--card); }
.composer-input::placeholder { color: var(--text-3); }
.composer-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.composer-footer .composer-count { margin-left: auto; }
.composer-count { font-size: 0.8rem; color: var(--text-3); white-space: nowrap; }
.composer-count.warn { color: var(--gold); }
.composer-count.over { color: var(--danger); }

/* ── Profile ────────────────────────────── */
.profile-header { padding: 24px; display: flex; align-items: flex-start; gap: 20px; }
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}
.profile-avatar-placeholder {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--success-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; color: var(--success);
  border: 3px solid var(--border);
}
.profile-info { flex: 1; min-width: 0; }
.profile-username { font-size: 1.375rem; font-weight: 700; }
.profile-addiction { font-size: 0.875rem; color: var(--text-2); margin-top: 3px; }
.profile-status { font-size: 0.875rem; color: var(--success); font-weight: 600; margin-top: 4px; }
.profile-rating { font-size: 0.875rem; color: var(--text-2); margin-top: 4px; }
.profile-rating strong { color: var(--gold); }
.profile-stats { display: flex; gap: 20px; margin-top: 12px; }
.stat-item { text-align: center; }
.stat-value { font-size: 1.25rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--text-2); }

/* ── Rating breakdown ────────────────────────── */
.rating-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px;
  align-items: stretch;
}

/* ── Achievements ───────────────────────── */
/* ── Achievements ───────────────────────── */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  padding: 14px 16px 16px;
}
.achievement-item {
  border-radius: 12px;
  padding: 14px 8px 10px;
  text-align: center;
  border: 1.5px solid var(--border);
  background: var(--card);
  transition: all 0.18s;
  cursor: default;
  position: relative;
}
.achievement-item.earned {
  background: var(--gold-light);
  border-color: #F0C040;
  box-shadow: 0 2px 10px rgba(245,166,35,0.18);
}
.achievement-item.earned:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(245,166,35,0.25); }
.achievement-item.locked { opacity: 0.38; filter: grayscale(0.8); }
.achievement-item.next-up {
  opacity: 0.75;
  border-style: dashed;
  border-color: var(--success);
  background: var(--success-light);
}
.achievement-emoji { font-size: 1.85rem; line-height: 1; margin-bottom: 5px; display: block; }
.achievement-label { font-size: 0.68rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.achievement-desc  { font-size: 0.6rem;  color: var(--text-3); margin-top: 2px; line-height: 1.3; }
.achievement-earned-date { font-size: 0.6rem; color: var(--gold); margin-top: 3px; font-weight: 600; }
.achievement-new-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--success); color: #fff;
  font-size: 0.55rem; font-weight: 700; padding: 2px 5px;
  border-radius: 8px; letter-spacing: 0.04em;
}
.achievements-category-title {
  font-size: 0.72rem; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 14px 16px 2px;
}
.achievements-next-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 14px;
  padding: 10px 14px;
  background: var(--success-light);
  border-radius: 10px;
  border: 1px solid #B9EDD4;
}
.achievements-next-bar .next-emoji { font-size: 1.4rem; flex-shrink: 0; }
.achievements-next-bar .next-info { flex: 1; min-width: 0; }
.achievements-next-bar .next-label { font-size: 0.8rem; font-weight: 700; color: var(--success); }
.achievements-next-bar .next-sub { font-size: 0.72rem; color: var(--text-2); margin-top: 1px; }
.achievements-progress-track {
  height: 5px; background: var(--border); border-radius: 3px; margin-top: 6px; overflow: hidden;
}
.achievements-progress-fill { height: 100%; border-radius: 3px; background: var(--success); transition: width 0.6s ease; }


/* ── Leaderboard ────────────────────────── */
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.leaderboard-item:last-child { border-bottom: none; }
.leaderboard-item:hover { background: var(--bg); }
.leaderboard-rank { font-size: 1rem; font-weight: 700; color: var(--text-3); width: 28px; text-align: center; flex-shrink: 0; }
.leaderboard-rank.top1 { color: #FFD700; font-size: 1.2rem; }
.leaderboard-rank.top2 { color: #C0C0C0; font-size: 1.1rem; }
.leaderboard-rank.top3 { color: #CD7F32; }
.leaderboard-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--bg); flex-shrink: 0; }
.leaderboard-avatar-ph {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: var(--primary);
  flex-shrink: 0;
}
.leaderboard-info { flex: 1; min-width: 0; }
.leaderboard-username { font-weight: 600; font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-meta { font-size: 0.78rem; color: var(--text-2); margin-top: 2px; }
.leaderboard-score { font-weight: 700; color: var(--gold); font-size: 1.05rem; }

/* ── Sidebar Widget ─────────────────────── */
.sidebar-widget { margin-bottom: 16px; }
.widget-title { font-size: 0.875rem; font-weight: 600; color: var(--text-2); padding: 14px 16px 8px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Auth Pages ─────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-card { width: 100%; max-width: 420px; border-radius: 20px; overflow: hidden; }
.auth-header { padding: 28px 28px 20px; text-align: center; }
.auth-logo { font-size: 1.5rem; font-weight: 800; color: var(--success); margin-bottom: 6px; }
.auth-tagline { font-size: 0.875rem; color: var(--text-2); }
.auth-body { padding: 0 28px 28px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-divider span { font-size: 0.8rem; color: var(--text-3); font-weight: 500; white-space: nowrap; }
.auth-footer { text-align: center; padding: 16px 28px 24px; border-top: 1px solid var(--border); font-size: 0.875rem; color: var(--text-2); }
.auth-footer a { color: var(--success); }

/* ── Addiction Selector ─────────────────── */
.addiction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.addiction-option {
  padding: 12px 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.18s;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.addiction-option:hover { border-color: var(--success); background: var(--success-light); }
.addiction-option.selected { border-color: var(--success); background: var(--success-light); color: var(--success); }
.addiction-option .emoji { font-size: 1.5rem; }

/* ── Steps ──────────────────────────────── */
.steps { display: flex; gap: 6px; margin-bottom: 24px; }
.step { flex: 1; height: 4px; border-radius: 2px; background: var(--border); transition: background 0.3s; }
.step.active { background: var(--success); }
.step.done { background: var(--success); }

/* ── Captcha ────────────────────────────── */
.captcha-box {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.captcha-question { font-weight: 700; font-size: 1.125rem; color: var(--text); flex-shrink: 0; }
.captcha-input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  width: 80px;
  background: var(--card);
}
.captcha-input:focus { outline: none; border-color: var(--success); }

/* ── Loading ────────────────────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9375rem; }

/* ── Tag / Badge ────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-green { background: var(--success-light); color: #1D8A55; }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-gold { background: var(--gold-light); color: #B07200; }

/* ── Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal h2 { margin-bottom: 8px; }
.modal p { color: var(--text-2); font-size: 0.9rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ── Utilities ──────────────────────────── */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }

/* ── Rules Page ─────────────────────────── */
.rules-page { max-width: 680px; margin: 0 auto; padding: 80px 16px 40px; }
.rules-page h1 { margin-bottom: 8px; }
.rules-list { list-style: none; margin-top: 20px; }
.rules-list li {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.5;
}
.rules-list li:last-child { border-bottom: none; }
.rule-num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: 0.875rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }

/* ── Post Actions (likes/comments/reposts) ──── */
.post-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.action-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  border: none; background: none;
  border-radius: 8px;
  font-size: 0.82rem; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.action-btn:hover { background: var(--bg); color: var(--text); }
.action-btn.liked { color: var(--success); }
.action-btn.reposted { color: var(--success); }
.action-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.action-btn.locked { opacity: 0.45; cursor: not-allowed; }

/* ── Comments ──────────────────────────────── */
.comments-section { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.comment-item { display: flex; gap: 8px; margin-bottom: 10px; }
.comment-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg); }
.comment-avatar-ph { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-username { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.comment-text { font-size: 0.875rem; color: var(--text); margin-top: 2px; word-break: break-word; }
.comment-meta { font-size: 0.72rem; color: var(--text-3); margin-top: 2px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-input { flex: 1; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 20px; font-size: 0.875rem; font-family: inherit; background: var(--bg); color: var(--text); }
.comment-input:focus { outline: none; border-color: var(--success); box-shadow: 0 0 0 3px rgba(61,184,122,0.15); background: white; }
.comment-submit { padding: 7px 14px; border-radius: 20px; font-size: 0.82rem; }

/* ── Rating Bar ──────────────────────────────── */
.rating-bar-section { padding: 16px 20px; border-top: 1px solid var(--border); }
.rating-tier-label {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.tier-name { font-weight: 700; font-size: 0.9375rem; }
.tier-points { font-size: 0.8rem; color: var(--text-2); }
.rating-bar-track { height: 10px; background: var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 6px; }
.rating-bar-fill { height: 100%; border-radius: 10px; transition: width 0.6s ease; }
.rating-bar-milestones { display: flex; justify-content: space-between; margin-top: 4px; }
.milestone { font-size: 0.62rem; color: var(--text-3); text-align: center; }
.milestone.reached { color: var(--text-2); font-weight: 600; }

/* ── Default Avatar Picker ──────────────────── */
.avatar-picker { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.avatar-option {
  width: 56px; height: 56px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; transition: all 0.18s; overflow: hidden;
}
.avatar-option img { width: 100%; height: 100%; object-fit: cover; }
.avatar-option:hover { border-color: var(--primary); transform: scale(1.08); }
.avatar-option.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ── Cookie Banner ───────────────────────────── */
#cookieBanner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: var(--card);
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.10);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  padding: 0;
}
#cookieBanner.cookie-visible { transform: translateY(0); }
.cookie-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.cookie-icon { font-size: 1.6rem; flex-shrink: 0; }
.cookie-text {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 240px;
}
.cookie-text strong { display: block; margin-bottom: 3px; font-size: 0.9rem; }
.cookie-text p { margin: 0; font-size: 0.78rem; color: var(--text-2); line-height: 1.5; }
.cookie-text a { color: var(--primary); text-decoration: underline; }
.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.cookie-btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.cookie-btn-secondary {
  background: var(--bg);
  color: var(--text-2);
  border: 1.5px solid var(--border);
}
.cookie-btn-secondary:hover { background: var(--border); }
.cookie-btn-primary {
  background: var(--primary);
  color: #fff;
}
.cookie-btn-primary:hover { background: var(--primary-dark, #2fa368); }
@media (max-width: 720px) {
  .cookie-inner { padding: 14px 16px; gap: 12px; }
  .cookie-actions { width: 100%; }
  .cookie-btn { flex: 1; text-align: center; }
}

/* ── Footer ─────────────────────────────────── */
.site-footer {
  background: var(--text);
  color: rgba(255,255,255,0.55);
  padding: 28px 16px;
  text-align: center;
  font-size: 0.8rem;
  margin-top: 48px;
}
@media (max-width: 720px) {
  .site-footer { padding-bottom: 92px !important; }
}
.site-footer a { color: rgba(255,255,255,0.7); text-decoration: none; }
.site-footer a:hover { color: white; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 12px; }
.footer-logo { font-size: 1rem; font-weight: 700; color: white; margin-bottom: 10px; }

/* ── Clean Since Date ────────────────────────── */
.date-info-box { background: var(--success-light); border: 1px solid #B9EDD4; border-radius: 8px; padding: 10px 12px; font-size: 0.82rem; color: #1D8A55; margin-top: 6px; }

/* ── Locked button shake ─────────────────────── */
@keyframes shakeLocked {
  0%,100% { transform: translateX(0) scale(1); }
  20%     { transform: translateX(-5px) scale(1.05); }
  40%     { transform: translateX(5px) scale(1.05); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}
.shake-locked { animation: shakeLocked 0.38s ease; }

/* ── Gift Rating Button ──────────────────────── */
.gift-btn { font-size: 0.8rem; padding: 4px 10px; border-radius: 20px; }

/* ── Topic filter row ────────────────────────── */
.topic-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 12px;
  margin-bottom: 20px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
  flex-shrink: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.topic-chip:hover:not(.active) {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}
.topic-chip:active { transform: scale(0.96); }
.topic-chip.active {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  font-weight: 600;
}
.topic-chip.active:hover {
  background: #2fa368;
  border-color: #2fa368;
}

/* ── Topic badge on post ─────────────────────── */
.topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ── Private post badge ──────────────────────── */
.private-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  background: #F3F4F6;
  color: var(--text-2);
  margin-bottom: 8px;
  margin-left: 6px;
}

/* ── Composer topic row ──────────────────────── */
.composer-topic {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}
.composer-topic-label {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
  padding-right: 2px;
}

.ctopic-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.ctopic-btn:hover:not(.selected) {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}
.ctopic-btn:active { transform: scale(0.95); }
.ctopic-btn.selected {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  font-weight: 600;
}

/* ── Visibility segmented control ───────────── */
.vis-segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  flex-shrink: 0;
}
.vis-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  background: transparent;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.vis-seg-btn.selected {
  background: #374151;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.vis-seg-btn:active { transform: scale(0.95); }

/* ── Subscription plan rows ─────────────────── */
.sub-plan-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--card);
  margin-bottom: 8px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.sub-plan-row:hover { border-color: var(--primary); background: var(--primary-light); }
.sub-plan-row:active { transform: scale(0.99); }
.sub-plan-row.selected { border-color: var(--primary); background: var(--primary-light); }
.sub-plan-row .plan-radio {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.sub-plan-row.selected .plan-radio { border-color: var(--primary); background: var(--primary); }
.sub-plan-row.selected .plan-radio::after {
  content: '';
  width: 6px; height: 6px;
  background: #fff;
  border-radius: 50%;
}
.sub-plan-row .plan-price {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  min-width: 38px;
}
.sub-plan-row.selected .plan-price { color: var(--primary); }
.sub-plan-row .plan-label {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
}
.sub-plan-row .plan-save-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--success);
  background: #E8F5E9;
  padding: 3px 9px;
  border-radius: 8px;
  white-space: nowrap;
}
.sub-plan-row .plan-popular {
  position: absolute;
  top: -9px; right: 14px;
  background: var(--gold);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ── Subscription card in profile ───────────── */
.sub-status-active {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #EAF6FF 0%, #E8F8F2 100%);
  border: 1.5px solid #90CDF4;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.sub-status-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  background: #1D9BF0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.sub-status-inactive {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.84rem;
  color: var(--text-2);
  line-height: 1.5;
}

.sub-plan-mini {
  flex: 1;
  position: relative;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 8px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  background: var(--card);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.sub-plan-mini:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(229,57,53,0.14);
}
.sub-plan-mini:active { transform: scale(0.96); box-shadow: none; }
.sub-plan-mini.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 4px 16px rgba(229,57,53,0.2);
}
.sub-plan-mini .price {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.sub-plan-mini.selected .price { color: var(--primary); }
.sub-plan-mini .period {
  font-size: 0.7rem;
  color: var(--text-2);
  margin-top: 4px;
  font-weight: 500;
}
.sub-plan-mini .saving {
  font-size: 0.65rem;
  color: var(--success);
  font-weight: 700;
  margin-top: 4px;
}
.sub-plan-mini .check-icon {
  display: none;
  position: absolute;
  top: -8px; right: -8px;
  width: 20px; height: 20px;
  background: var(--primary);
  border-radius: 50%;
  align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(229,57,53,0.4);
}
.sub-plan-mini.selected .check-icon { display: flex; }
.sub-plan-popular-badge {
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--gold);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 10px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.sub-pay-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #C62828 100%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 14px rgba(229,57,53,0.35);
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}
.sub-pay-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(229,57,53,0.45);
}
.sub-pay-btn:active { transform: scale(0.97); box-shadow: none; }
.sub-pay-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Toggle Switch ───────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── AI Report ───────────────────────────────── */
.ai-report-text { font-size: 0.875rem; line-height: 1.65; color: var(--text); }
.ai-report-text p { margin: 6px 0; }
.ai-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 8px;
  padding-bottom: 7px;
  border-bottom: 1.5px solid var(--border);
}
.ai-section-title:first-child { margin-top: 0; }
.ai-list-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 5px 0;
  font-size: 0.875rem;
  line-height: 1.5;
}
.ai-list-num {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.ai-list-bullet {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  line-height: 1.4;
}
.ai-quote {
  background: linear-gradient(135deg, #f0f4ff 0%, #f5f0ff 100%);
  border-left: 3px solid #764ba2;
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 6px 0;
  font-style: italic;
  font-weight: 500;
  color: #4a3a6e;
  font-size: 0.875rem;
}

/* ── Mobile: composer & feed improvements ── */
@media (max-width: 720px) {
  .composer { padding: 12px; }
  .composer-inner { gap: 8px; }
  .composer-input { font-size: 0.9rem; padding: 10px 12px; min-height: 72px; }
  .composer-footer { margin-top: 8px; }
  .composer-footer .btn { padding: 8px 16px; font-size: 0.875rem; }

  /* Composer topic: равная сетка 4 колонки */
  .composer-topic {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    align-items: stretch;
  }
  .composer-topic-label { display: none; }
  .ctopic-btn {
    justify-content: center;
    padding: 7px 4px;
    font-size: 0.75rem;
    width: 100%;
    white-space: normal;
    text-align: center;
    word-break: break-word;
    min-width: 0;
    line-height: 1.3;
  }

  /* Topic filter: равная сетка 3 колонки */
  .topic-filter {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .topic-chip {
    justify-content: center;
    padding: 7px 4px;
    font-size: 0.75rem;
    white-space: normal;
    text-align: center;
    word-break: break-word;
    flex-shrink: 1;
    min-width: 0;
    line-height: 1.3;
  }

  /* Premium gate bottom sheet */
  .premium-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    animation: fadeInOverlay 0.2s ease;
  }
  .premium-sheet {
    background: var(--card);
    border-radius: 20px 20px 0 0;
    padding: 12px 24px 36px;
    width: 100%;
    animation: slideUpSheet 0.32s cubic-bezier(0.34,1.4,0.64,1);
  }
  .premium-sheet-handle {
    width: 44px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 22px;
  }
  @keyframes slideUpSheet {
    from { transform: translateY(100%); opacity: 0.4; }
    to   { transform: translateY(0);   opacity: 1;   }
  }
  @keyframes fadeInOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* Profile: rating section стакуется в 1 колонку */
  .rating-breakdown-grid {
    grid-template-columns: 1fr;
  }

  /* Profile header — вертикальный layout на мобиле */
  .profile-header {
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 16px;
    gap: 10px;
    text-align: center;
  }
  .profile-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .profile-avatar,
  .profile-avatar-placeholder {
    width: 72px;
    height: 72px;
    font-size: 1.6rem;
  }
  .profile-info { width: 100%; }
  .profile-username {
    font-size: 1.1rem;
    word-break: break-word;
    justify-content: center;
  }
  .profile-addiction,
  .profile-status,
  .profile-rating { font-size: 0.82rem; }
  .profile-stats {
    justify-content: center;
    gap: 20px;
    flex-wrap: nowrap;
    margin-top: 10px;
  }
  .stat-value { font-size: 1.15rem; }
  .profile-timer { font-size: 1.25rem; }
  .profile-clean-since { font-size: 0.8rem; }
}

/* ── Prevent iOS Safari zoom on input focus ── */
@media (max-width: 720px) {
  input, textarea, select,
  .form-input, .composer-input, .comment-input, .captcha-input {
    font-size: 16px !important;
  }
}
