*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --terracotta: #FF3131;
  --terracotta-dark: #B31A1A;
  --terracotta-light: #FFDCDC;
  --ink: #1E1B18;
  --gray-900: #2A2724;
  --gray-700: #5C5852;
  --gray-500: #8A857D;
  --gray-300: #D8D4CC;
  --gray-100: #F3F1EC;
  --white: #FFFFFF;
}
[data-theme="dark"] {
  --ink: #F3F1EC;
  --gray-900: #EDEAE4;
  --gray-700: #B8B3AA;
  --gray-500: #8A857D;
  --gray-300: #333333;
  --gray-100: #161616;
  --white: #1F1F1F;
  --terracotta-light: #3D3D3D;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--ink);
  transition: background 0.15s, color 0.15s;
}

/* ── Topbar ── */
.topbar { background: var(--white); border-bottom: 1px solid var(--gray-300); display: flex; align-items: center; gap: 16px; padding: 0 24px; height: 60px; position: sticky; top: 0; z-index: 40; }
.logo { font-size: 20px; font-weight: 800; color: var(--ink); text-decoration: none; }
.logo span { color: var(--terracotta); }
.topbar-icons { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.topbar-icon { width: 38px; height: 38px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--gray-700); cursor: pointer; position: relative; text-decoration: none; border: none; background: none; }
.topbar-icon.active { background: var(--terracotta-light); color: var(--terracotta-dark); }
.topbar-icon.theme-btn { border: 1px solid var(--gray-300); }
.notif-badge { position: absolute; top: 4px; right: 4px; min-width: 8px; height: 8px; border-radius: 50%; background: var(--terracotta); border: 1.5px solid var(--white); }
.search { flex: 1; max-width: 420px; margin-left: 12px; }
.search input { width: 100%; border: 1px solid var(--gray-300); border-radius: 8px; padding: 9px 14px; font-size: 13px; background: var(--gray-100); outline: none; color: var(--ink); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--terracotta); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; text-decoration: none; cursor: pointer; border: none; }
.btn-post { background: var(--terracotta); color: white; border: none; border-radius: 8px; padding: 9px 18px; font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: none; }
.auth-links { display: flex; gap: 8px; align-items: center; }
.auth-links a { font-size: 13px; font-weight: 700; text-decoration: none; padding: 8px 14px; border-radius: 8px; }
.auth-links .login-link { color: var(--gray-700); }
.auth-links .signup-link { background: var(--terracotta); color: white; }
.back-link { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--gray-700); text-decoration: none; }

/* ── Account dropdown ── */
.dropdown { position: absolute; top: 48px; right: 0; width: 250px; background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); display: none; overflow: hidden; z-index: 50; }
.dropdown.open { display: block; }
.dd-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.dd-name { font-weight: 700; font-size: 14px; }
.dd-group { border-top: 1px solid var(--gray-300); padding: 6px 0; }
.dd-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--gray-900); cursor: pointer; text-decoration: none; }
.dd-item:hover { background: var(--gray-100); }
.dd-count { font-size: 12px; font-weight: 700; color: var(--gray-500); }

/* ── Layout ── */
.layout { display: grid; grid-template-columns: 240px 1fr 300px; gap: 20px; max-width: 1180px; margin: 20px auto; padding: 0 20px; align-items: start; }
.wrap { max-width: 700px; margin: 24px auto; padding: 0 20px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .layout > .sidebar, .layout > .ad-col { display: none; }
}

/* ── Sidebar ── */
.sidebar { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; padding: 16px; position: sticky; top: 80px; }
.sidebar-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); margin-bottom: 10px; }
.cat-item { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--gray-900); cursor: pointer; text-decoration: none; }
.cat-item:hover { background: var(--gray-100); }
.cat-item.active { background: var(--terracotta-light); color: var(--terracotta-dark); }

/* ── Feed cards ── */
.feed-card { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.feed-image { width: 100%; height: 220px; object-fit: cover; display: block; }
.feed-card-body { padding: 16px 18px; }
.feed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.feed-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--terracotta-light); color: var(--terracotta-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.feed-name { font-size: 13px; font-weight: 700; color: var(--ink); text-decoration: none; }
.feed-meta { font-size: 11.5px; color: var(--gray-500); }
.feed-tag { display: inline-block; background: var(--terracotta-light); color: var(--terracotta-dark); font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-left: 6px; text-decoration: none; }
.feed-title { font-size: 15.5px; font-weight: 700; color: var(--ink); margin: 6px 0 6px; line-height: 1.4; text-decoration: none; display: block; }
.feed-excerpt { font-size: 13.5px; color: var(--gray-700); line-height: 1.6; }
.feed-actions { display: flex; align-items: center; gap: 18px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--gray-100); font-size: 12.5px; color: var(--gray-500); font-weight: 600; position: relative; }
.feed-actions span, .vote-btn { display: flex; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 12.5px; font-weight: 600; padding: 0; }
.vote-btn.voted-up { color: var(--terracotta); }
.vote-btn.voted-down { color: #3378DD; }
.bookmark-btn.saved { color: var(--terracotta); }
.more-trigger { margin-left: auto; cursor: pointer; font-size: 16px; padding: 2px 8px; border-radius: 6px; position: relative; }
.more-trigger:hover { background: var(--gray-100); color: var(--terracotta); }

/* ── Image carousel ── */
.carousel { position: relative; width: 100%; height: 220px; overflow: hidden; }
.carousel-track { display: flex; height: 100%; transition: transform 0.25s ease; }
.carousel-track img { width: 100%; height: 220px; object-fit: cover; flex-shrink: 0; display: block; }
.carousel-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,0.45); color: white; border: none; display: flex; align-items: center; justify-content: center; font-size: 14px; cursor: pointer; }
.carousel-arrow.prev { left: 10px; }
.carousel-arrow.next { right: 10px; }
.carousel-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; }
.carousel-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.55); }
.carousel-dot.active { background: white; width: 16px; border-radius: 3px; }
.carousel-count { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.45); color: white; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }

/* ── Share callout ── */
.share-callout { position: absolute; bottom: 34px; right: 0; width: 168px; background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.14); padding: 6px 0; display: none; z-index: 30; }
.share-callout.open { display: block; }
.share-callout::after { content: ''; position: absolute; bottom: -7px; right: 14px; width: 12px; height: 12px; background: var(--white); border-right: 1px solid var(--gray-300); border-bottom: 1px solid var(--gray-300); transform: rotate(45deg); }
.share-head { font-size: 11px; font-weight: 700; color: var(--gray-500); padding: 8px 14px 6px; }
.share-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--gray-900); cursor: pointer; }
.share-item:hover { background: var(--gray-100); color: var(--terracotta); }

/* ── Empty / ad / misc ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state-icon { font-size: 32px; margin-bottom: 10px; }
.load-more { display: block; text-align: center; background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; padding: 12px; font-size: 13px; font-weight: 700; color: var(--gray-700); text-decoration: none; margin-top: 6px; }
.sort-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.sort-tab { background: var(--white); border: 1px solid var(--gray-300); border-radius: 20px; padding: 8px 16px; font-size: 12.5px; font-weight: 700; color: var(--gray-700); text-decoration: none; }
.sort-tab.active { background: var(--terracotta); color: white; border-color: var(--terracotta); }
.ad-slot { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; height: 250px; display: flex; align-items: center; justify-content: center; color: var(--gray-500); font-size: 12px; margin-bottom: 16px; }
.stats-widget { background: var(--white); border: 1px solid var(--gray-300); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.stats-widget-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); margin-bottom: 12px; }
.stats-widget-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stats-widget-box { background: linear-gradient(150deg, var(--terracotta-light), var(--gray-100)); border-radius: 12px; padding: 14px 8px; text-align: center; }
.stats-widget-num { display: block; font-size: 20px; font-weight: 800; color: var(--terracotta-dark); font-family: Georgia, serif; line-height: 1.1; }
.stats-widget-label { display: block; font-size: 10.5px; color: var(--gray-700); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 4px; }
.stats-widget-link { display: block; text-align: center; font-size: 11.5px; color: var(--terracotta); font-weight: 700; text-decoration: none; padding-top: 4px; border-top: 1px solid var(--gray-100); }
.stats-widget-link:hover { text-decoration: underline; }
.sidebar-footer-links { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--gray-300); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.sidebar-footer-links a { font-size: 11px; color: var(--gray-500); text-decoration: none; }
.sidebar-footer-links a:hover { color: var(--terracotta); }

/* ── Static content pages (About, Terms, Privacy, etc.) ── */
.content-wrap { max-width: 640px; margin: 32px auto; padding: 0 20px 60px; }
.content-wrap h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.content-updated { font-size: 12px; color: var(--gray-500); margin-bottom: 24px; }
.content-wrap h2 { font-size: 16px; font-weight: 800; margin: 26px 0 10px; }
.content-wrap h3 { font-size: 13.5px; font-weight: 800; margin: 16px 0 8px; color: var(--gray-900); }
.content-wrap .toc { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; padding: 16px 18px; margin-bottom: 28px; }
.content-wrap .toc-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); margin-bottom: 10px; }
.content-wrap .toc a { display: block; font-size: 13px; color: var(--gray-900); font-weight: 600; text-decoration: none; padding: 3px 0; }
.content-wrap .toc a:hover { color: var(--terracotta); }
.content-wrap p { font-size: 14px; color: var(--gray-900); line-height: 1.75; margin-bottom: 14px; }
.content-wrap ul { margin: 0 0 14px 20px; }
.content-wrap li { font-size: 14px; color: var(--gray-900); line-height: 1.75; margin-bottom: 6px; }
.content-wrap a { color: var(--terracotta); text-decoration: none; font-weight: 600; }
