/* ===== CSS Variables / Theme ===== */
:root, [data-theme="light"] {
    --bg: #F0F2F5;
    --bg-card: #FFFFFF;
    --bg-hover: #F8FAFC;
    --bg-input: #FFFFFF;
    --text-primary: #1A1A2E;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --primary-light: rgba(99,102,241,.1);
    --upvote: #FF4500;
    --downvote: #7950F2;
    --success: #22C55E;
    --danger: #EF4444;
    --warning: #F59E0B;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 14px rgba(0,0,0,.1);
    --radius: 12px;
    --radius-sm: 8px;
    --nav-bg: #1A1A2E;
    --nav-text: #E2E8F0;
}

[data-theme="dark"] {
    --bg: #0F0F1A;
    --bg-card: #1A1A2E;
    --bg-hover: #252540;
    --bg-input: #252540;
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: #2D2D4A;
    --border-light: #252540;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-lg: 0 4px 14px rgba(0,0,0,.4);
    --nav-bg: #12121F;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }

/* ===== Navbar ===== */
.navbar {
    background: var(--nav-bg);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 56px;
    gap: 16px;
}
.nav-left { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.nav-brand {
    font-size: 20px;
    font-weight: 800;
    color: #fff !important;
    letter-spacing: -0.5px;
}
.nav-links { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; align-items: center; }
.nav-links li { display: block; }
.nav-links .nav-link {
    color: rgba(255,255,255,.78);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background .15s, color .15s;
    display: inline-block;
}
.nav-links .nav-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-links .nav-link.active { color: #fff; background: rgba(255,255,255,.16); }
@media (max-width: 760px) {
    .nav-links { display: none; }
}
.nav-search { flex: 1; max-width: 520px; position: relative; }
.search-form { position: relative; }
.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: background .15s;
}
.search-clear:hover { background: rgba(255,255,255,.3); }

/* ===== Live search dropdown ===== */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .15);
    max-height: 70vh;
    overflow-y: auto;
}
.search-state { padding: 14px 16px; color: var(--text-secondary); font-size: 13px; }
.search-state-empty .search-state-hint,
.search-state-noresults .search-state-hint { margin: 0; }
.search-state-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}
.search-loading-spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ltf-spin .8s linear infinite;
}
.search-section { padding: 4px 6px 6px; }
.search-section + .search-section { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }
.search-section-head {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-muted);
    padding: 6px 10px;
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: background .12s;
    cursor: pointer;
}
.search-result-item:hover,
.search-result-item.is-active { background: var(--bg-input, rgba(0,0,0,.04)); }
.search-result-item.is-active { outline: 2px solid var(--primary); outline-offset: -2px; }
.search-result-img {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-input, #f1f5f9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
}
.search-result-img-placeholder { background: linear-gradient(135deg, var(--primary), #8B5CF6); }
.search-result-avatar,
.search-result-avatar.search-result-img-placeholder { border-radius: 50%; }
.search-result-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-result-title {
    font-size: 14px; font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-meta {
    font-size: 12px; color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-dropdown-footer {
    border-top: 1px solid var(--border);
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.search-viewall {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}
.search-viewall:hover { text-decoration: underline; }
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 9px 16px 9px 42px;
    border: 2px solid transparent;
    border-radius: 24px;
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 14px;
    transition: all .2s;
}
.search-input::placeholder { color: rgba(255,255,255,.4); }
.search-input:focus {
    outline: none;
    background: rgba(255,255,255,.15);
    border-color: var(--primary);
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.nav-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--nav-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    position: relative;
}
.nav-icon-btn:hover { background: rgba(255,255,255,.1); }
.nav-notif { position: relative; }
.notif-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}
.notif-badge-sm {
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 4px;
}

/* User dropdown */
.nav-user { position: relative; }
.nav-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border: none;
    background: rgba(255,255,255,.08);
    border-radius: 24px;
    color: var(--nav-text);
    font-size: 13px;
    font-weight: 600;
    transition: background .2s;
}
.nav-user-btn:hover { background: rgba(255,255,255,.15); }
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 6px;
    display: none;
    z-index: 200;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: block;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Theme toggle */
.theme-toggle .sun-icon { display: block; }
.theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .moon-icon { display: block; }

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
}
.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--nav-text);
    border-radius: 2px;
    transition: all .2s;
}

/* ===== Mobile Sidebar ===== */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--bg-card);
    z-index: 300;
    transition: left .3s ease;
    overflow-y: auto;
}
.mobile-sidebar.open { left: 0; }
.mobile-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 16px;
}
.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-hover);
    border-radius: 50%;
    font-size: 20px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-sidebar-content { padding: 12px; }
.sidebar-link {
    display: block;
    padding: 10px 14px;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: background .15s;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 0; }
.sidebar-heading {
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
}
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.5);
    z-index: 250;
    display: none;
}
.sidebar-overlay.show { display: block; }

/* ===== Layout ===== */
.main-content { min-height: calc(100vh - 56px - 60px); }
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.content-area { flex: 1; min-width: 0; }
.content-area.full-width { max-width: 100%; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.card-header h2 { font-size: 18px; }
.card-body { padding: 20px; }

/* ===== Sidebar (Desktop) ===== */
.sidebar { width: 340px; flex-shrink: 0; }
.sidebar-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 16px;
}
.sidebar-card-header {
    padding: 12px 16px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.sidebar-card-body { padding: 16px; }
.home-banner {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    padding: 24px 16px;
    font-size: 18px;
    text-transform: none;
    letter-spacing: 0;
}

/* Community info card */
.community-banner-sm {
    height: 80px;
    background-size: cover;
    background-position: center;
}
.community-sidebar-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.community-sidebar-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.community-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    text-align: center;
}
.stat-value { font-weight: 700; font-size: 16px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.community-list { list-style: none; }
.community-list li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    transition: background .15s;
}
.community-list li a:hover { background: var(--bg-hover); }
.community-rank { font-weight: 700; color: var(--text-muted); width: 20px; text-align: right; }
.community-list-name { flex: 1; font-weight: 600; }
.community-list-members { font-size: 12px; color: var(--text-muted); }
.rules-content { font-size: 14px; line-height: 1.7; }

/* ===== Community Header ===== */
.community-banner {
    height: 180px;
    background-size: cover;
    background-position: center;
}
.community-header-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.community-header-bar .container { padding-top: 0; padding-bottom: 0; }
.community-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    width: 100%;
}
.community-identity { display: flex; align-items: center; gap: 16px; }
.community-icon-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 4px solid var(--bg-card);
    margin-top: -24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}
img.community-icon-lg { object-fit: cover; }
.community-title { font-size: 22px; font-weight: 800; }

/* ===== Feed / Sort ===== */
.feed-header {
    margin-bottom: 16px;
}
.sort-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
}
.sort-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all .15s;
}
.sort-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.sort-tab.active { background: var(--primary-light); color: var(--primary); }
.sort-tab svg { flex-shrink: 0; }

/* ===== Post Cards ===== */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-card {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color .15s;
    overflow: hidden;
}
.post-card:hover { border-color: var(--text-muted); }

/* Vote controls */
.vote-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    gap: 2px;
    background: var(--border-light);
    flex-shrink: 0;
    min-width: 48px;
}
.vote-btn {
    width: 32px;
    height: 28px;
    border: none;
    background: none;
    border-radius: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    padding: 0;
}
.vote-btn:hover { background: var(--bg-hover); }
.vote-btn.upvote.active { color: var(--upvote); }
.vote-btn.upvote:hover { color: var(--upvote); }
.vote-btn.downvote.active { color: var(--downvote); }
.vote-btn.downvote:hover { color: var(--downvote); }
.vote-score {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    min-width: 24px;
}
.vote-score.positive { color: var(--upvote); }
.vote-score.negative { color: var(--downvote); }

/* Post content */
.post-content { flex: 1; padding: 12px 16px; min-width: 0; }
.post-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.post-community { font-weight: 700; color: var(--text-primary); }
.post-community:hover { text-decoration: underline; color: var(--text-primary); }
.meta-dot { color: var(--text-muted); }
.post-author a { color: var(--text-muted); }
.post-author a:hover { text-decoration: underline; color: var(--text-secondary); }
.post-time { color: var(--text-muted); }
.post-title { font-size: 17px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; }
.post-title a { color: var(--text-primary); }
.post-title a:hover { color: var(--primary); }
.post-domain { font-size: 12px; color: var(--primary); font-weight: 400; }
.post-excerpt {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
    max-height: 60px;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, black 50%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent);
}
.post-thumbnail {
    display: block;
    margin-bottom: 8px;
}
.post-thumbnail img, .post-image-preview img {
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

/* Post actions bar */
.post-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}
.post-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all .15s;
}
.post-action-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-pin { background: rgba(34,197,94,.15); color: var(--success); }
.badge-lock { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-admin { background: var(--primary-light); color: var(--primary); }
.badge-banned { background: rgba(239,68,68,.15); color: var(--danger); }
.badge-active { background: rgba(34,197,94,.15); color: var(--success); }
.badge-user { background: var(--bg-hover); color: var(--text-secondary); }
.badge-moderator { background: rgba(34,197,94,.15); color: var(--success); }
.badge-pending { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-reviewed { background: rgba(34,197,94,.15); color: var(--success); }
.badge-dismissed { background: var(--bg-hover); color: var(--text-muted); }

/* ===== Post Detail ===== */
.post-detail { margin-bottom: 16px; }
.post-detail-inner { display: flex; }
.post-detail-content { flex: 1; padding: 16px 20px; min-width: 0; }
.post-detail-title { font-size: 22px; font-weight: 700; line-height: 1.3; margin-bottom: 12px; }
.post-body {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 16px;
    word-wrap: break-word;
}
.post-body code { background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.post-body strong { font-weight: 700; }
.post-body a { color: var(--primary); }
.post-link-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    color: var(--text-primary);
    transition: border-color .2s;
}
.post-link-card:hover { border-color: var(--primary); color: var(--text-primary); }
.link-thumb { width: 100px; height: 70px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.link-info { flex: 1; min-width: 0; }
.link-url { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--primary); }
.link-domain { font-size: 12px; color: var(--text-muted); }
.post-image-full { margin-bottom: 16px; }
.post-image-full img { border-radius: var(--radius); max-height: 600px; object-fit: contain; }

/* ===== Comments - Reddit-style ===== */
.comments-section { margin-top: 8px; }
.comment-form-card { margin-bottom: 16px; }
.comment-as { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.comment-as a { color: var(--primary); font-weight: 600; }

/* Reddit-style "Join the conversation" pill: collapsed shows a single-line
   placeholder; expanded shows a textarea + actions. State is toggled via
   data-state on the wrapper. */
.comment-pill { margin-bottom: 16px; }
.comment-pill[data-state="expanded"] .comment-pill-collapsed { display: none; }
.comment-pill[data-state="collapsed"] .comment-pill-expanded  { display: none; }
.comment-pill-collapsed {
    display: block;
    width: 100%;
    padding: 11px 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 14px;
    font-family: inherit;
    cursor: text;
    text-align: left;
    transition: border-color .15s, background .15s, color .15s;
}
.comment-pill-collapsed:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.comment-pill-expanded {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px 14px 12px;
    background: var(--bg-card);
    transition: border-color .15s;
}
.comment-pill-expanded:focus-within { border-color: var(--primary); }
.comment-pill-expanded .comment-as { margin-bottom: 6px; }
.comment-pill-expanded textarea {
    width: 100%;
    border: none;
    background: transparent;
    resize: vertical;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.55;
    color: var(--text-primary);
    padding: 4px 0;
    outline: none;
    min-height: 80px;
}
.comment-pill-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

/* Thread line hover effects */
.thread-line-area:hover .thread-line { opacity: 1 !important; }
.thread-line-area:hover .collapse-toggle { color: var(--primary) !important; background: var(--primary-light); }
.collapse-toggle:hover { color: var(--primary) !important; background: var(--primary-light); }

/* Vote button hover */
.vote-btn-inline:hover { background: var(--bg-hover); }
.vote-btn-inline.upvote.active, .vote-btn-inline.upvote:hover { color: var(--upvote); }
.vote-btn-inline.downvote.active, .vote-btn-inline.downvote:hover { color: var(--downvote); }

/* Action button hover */
.comment-action-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

/* Comment body code blocks */
.comment-thread code { background: var(--bg-hover); padding: 1px 4px; border-radius: 3px; font-size: 12px; }

/* Reply/edit form */
/* Inline reply + edit forms pick up the same pill-expanded aesthetic as the
   top-level "Join the conversation" pill: subtle border, focus-within
   highlight, no chrome around the textarea. */
.reply-form-container, .edit-form-container { margin-top: 6px; }
.reply-form, .edit-form {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--bg-card);
    transition: border-color .15s;
}
.reply-form:focus-within, .edit-form:focus-within { border-color: var(--primary); }
.reply-form textarea, .edit-form textarea {
    width: 100%;
    border: none;
    background: transparent;
    resize: vertical;
    font-family: inherit;
    color: var(--text-primary);
    padding: 4px 0;
    outline: none;
}
.reply-form textarea:focus, .edit-form textarea:focus { outline: none; box-shadow: none; }

/* ===== User Profile ===== */
.user-profile-card { overflow: hidden; margin-bottom: 20px; }
.user-profile-header {
    height: 120px;
    display: flex;
    align-items: flex-end;
    padding: 0 20px 0;
}
.user-avatar-lg {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-card);
    border: 4px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: -40px;
    flex-shrink: 0;
}
.user-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.user-profile-body { padding: 48px 20px 20px; }
.user-profile-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-bio { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }
.user-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.user-stats .stat { text-align: center; }

/* ===== Auth Pages ===== */
.auth-container {
    max-width: 440px;
    margin: 40px auto;
    padding: 0 16px;
}
.auth-card { }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.auth-form { margin-bottom: 20px; }
.auth-footer { text-align: center; font-size: 14px; color: var(--text-secondary); }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .3px; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-input);
    transition: border-color .2s;
    font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* Post type tabs */
.post-type-tabs {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 18px;
}
.type-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all .15s;
    border-right: 1px solid var(--border);
}
.type-tab:last-child { border-right: none; }
.type-tab:hover { background: var(--bg-hover); }
.type-tab.active { background: var(--primary-light); color: var(--primary); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.nav-create-btn { border-radius: 24px; display: inline-flex; align-items: center; gap: 2px; }
.nav-create { position: relative; }
.nav-create-menu { min-width: 280px; padding: 8px; }
.nav-create-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text);
    border-radius: 8px;
    transition: background .15s, color .15s;
}
.nav-create-item:hover { background: var(--bg-input, rgba(0,0,0,.04)); }
.nav-create-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light, rgba(99,102,241,.1));
    color: var(--primary);
    border-radius: 8px;
    margin-top: 1px;
}
.nav-create-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-create-text strong { font-size: 14px; font-weight: 700; color: var(--text); }
.nav-create-text small { font-size: 12px; color: var(--text-secondary); }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.2); color: var(--danger); }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.2); color: var(--success); }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state h3 { color: var(--text-primary); margin-bottom: 8px; }

/* ===== Pagination ===== */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 24px; }
.page-btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Deal post-card additions ===== */
.post-card.is-deal { border-left: 3px solid var(--primary); }
.post-card.is-hot .vote-score { color: #DC2626 !important; font-weight: 800; }
.post-card.is-expired { opacity: .6; }
.post-card.is-expired .post-title a { text-decoration: line-through; }
.badge-hot { background: linear-gradient(135deg, #F97316, #DC2626); color: #fff; }
.badge-expired { background: #6B7280; color: #fff; }
.badge-retailer { background: var(--bg-input, #f1f5f9); color: var(--text-secondary); border: 1px solid var(--border); }
.deal-quickfacts { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 4px 0 8px; font-size: 14px; }
.deal-price { font-weight: 700; color: var(--primary); font-size: 16px; }
.deal-was { color: var(--text-secondary); font-size: 13px; }
.deal-pct { background: #DC2626; color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.deal-voucher { font-size: 13px; color: var(--text-secondary); }
.deal-voucher code { background: var(--bg-input, #f1f5f9); padding: 2px 8px; border-radius: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text); }

/* Deal detail block on post page */
.deal-info-card { background: linear-gradient(135deg, var(--primary-light, rgba(99,102,241,.08)) 0%, transparent 100%); border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 18px 20px; margin: 16px 0 20px; }
.deal-info-card.has-image { display: grid; grid-template-columns: 280px 1fr; gap: 22px; padding: 18px; align-items: stretch; }
.deal-info-card .deal-info-image { display: block; position: relative; border-radius: 10px; overflow: hidden; background: var(--bg-input, #f8fafc); aspect-ratio: 4/3; align-self: stretch; }
.deal-info-card .deal-info-image img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; padding: 8px; box-sizing: border-box; }
.deal-info-card .deal-info-image .deal-image-pct { position: absolute; top: 10px; left: 10px; background: #DC2626; color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.deal-info-card .deal-info-content { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.deal-info-card .deal-info-grid { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.deal-info-card .deal-price-block { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.deal-info-card .deal-price-big { font-size: 28px; font-weight: 800; color: var(--primary); letter-spacing: -.01em; }
.deal-info-card .deal-was-line { color: var(--text-secondary); font-size: 14px; }
.deal-info-card .deal-pct-big { background: #DC2626; color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.deal-info-card .deal-voucher-block { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.deal-info-card .deal-voucher-block code { background: var(--bg-card, #fff); padding: 4px 12px; border-radius: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; border: 1px dashed var(--primary); color: var(--text); }
.deal-info-card .copy-btn { background: transparent; border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.deal-info-card .copy-btn:hover { background: var(--bg-input, #f1f5f9); }
.deal-info-card .deal-cta { display: inline-flex; align-items: center; gap: 6px; background: var(--primary); color: #fff !important; padding: 10px 20px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.deal-info-card .deal-cta:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.deal-info-card .deal-meta-row { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); margin-top: 12px; flex-wrap: wrap; }
.deal-info-card.expired { opacity: .65; }
@media (max-width: 700px) {
    .deal-info-card.has-image { grid-template-columns: 1fr; gap: 14px; }
    .deal-info-card.has-image .deal-info-image { aspect-ratio: 16/10; max-height: 280px; }
}

/* ===== Deals listing ===== */
.deals-listing-shell { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.deals-listing-shell .deals-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.deals-listing-shell h1 { font-size: clamp(24px, 3vw, 32px); margin: 0; font-weight: 800; letter-spacing: -.01em; }
.deal-card-list { display: flex; flex-direction: column; gap: 12px; }

/* Deal card (image-left) — used on /deals listing */
.deal-card {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 16px;
    padding: 14px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    transition: transform .15s, box-shadow .15s;
    align-items: stretch;
}
.deal-card:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.07); border-color: var(--primary); }
.deal-card.is-expired { opacity: .6; }
.deal-card.is-expired .deal-card-title a { text-decoration: line-through; }
.deal-card.is-hot { border-color: #F97316; }

.deal-card-image {
    display: block;
    width: 180px;
    aspect-ratio: 4/3;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary, #6366F1), #8B5CF6);
    position: relative;
    flex-shrink: 0;
}
.deal-card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deal-card-image.image-failed img { display: none; }
.deal-card-image .deal-image-fallback {
    position: absolute; inset: 0; display: flex;
    align-items: center; justify-content: center;
    color: rgba(255,255,255,.85); font-weight: 800;
    font-size: 14px; letter-spacing: .08em; text-transform: uppercase;
    text-align: center; padding: 0 8px;
}
.deal-card-image .deal-image-pct {
    position: absolute; top: 8px; left: 8px;
    background: #DC2626; color: #fff;
    padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 800;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.deal-card-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.deal-card-meta-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-secondary); }
.deal-card-meta-row .meta-soft { font-size: 12px; color: var(--text-secondary); }
.deal-card-meta-row .meta-dot { color: var(--text-muted); opacity: .5; }
.badge-deal-cat { background: var(--primary-light, rgba(99,102,241,.1)); color: var(--primary); border: 1px solid transparent; text-decoration: none; }
.badge-deal-cat:hover { background: rgba(99,102,241,.15); }

.deal-card-title { font-size: 17px; line-height: 1.3; margin: 0; font-weight: 700; word-wrap: break-word; }
.deal-card-title a { color: var(--text); text-decoration: none; }
.deal-card-title a:hover { color: var(--primary); }

.deal-card-pricing { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; }
.deal-card-pricing .deal-price-big { font-size: 20px; font-weight: 800; color: var(--primary); letter-spacing: -.005em; }
.deal-card-pricing .deal-was { color: var(--text-secondary); font-size: 13px; }
.deal-card-pricing .deal-voucher { font-size: 13px; color: var(--text-secondary); }
.deal-card-pricing .deal-voucher code { background: var(--bg-input, #f1f5f9); padding: 2px 8px; border-radius: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text); }

.deal-card-excerpt { font-size: 13px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.deal-card-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.deal-card-actions .action-link { color: var(--text-secondary); font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.deal-card-actions .action-link:hover { color: var(--primary); }

.deal-card-vote {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 0 8px 0 12px;
    border-left: 1px solid var(--border, #e5e7eb);
    min-width: 64px;
}
.deal-card-vote .vote-temp { font-size: 16px; font-weight: 700; color: var(--text-secondary); }
.deal-card.is-hot .deal-card-vote .vote-temp { color: #DC2626; }
.deal-card-vote .vote-btn { background: transparent; border: none; cursor: pointer; padding: 4px; color: var(--text-secondary); border-radius: 4px; }
.deal-card-vote .vote-btn:hover { background: var(--bg-input, #f1f5f9); color: var(--primary); }
.deal-card-vote .vote-btn.upvote.active { color: #16A34A; }
.deal-card-vote .vote-btn.downvote.active { color: #DC2626; }

@media (max-width: 720px) {
    .deal-card { grid-template-columns: 110px 1fr; padding: 12px; gap: 12px; }
    .deal-card-image { width: 110px; aspect-ratio: 1/1; }
    .deal-card-vote {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: center;
        gap: 12px;
        border-left: none;
        border-top: 1px solid var(--border, #e5e7eb);
        padding: 8px 0 0;
    }
    .deal-card-title { font-size: 16px; }
    .deal-card-pricing .deal-price-big { font-size: 18px; }
}

/* ===== Admin ===== */
.admin-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    margin-bottom: 24px;
}
@media (max-width: 600px) {
    .admin-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-tabs .sort-tab { white-space: nowrap; }
}
.admin-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.admin-stat-card {
    background: var(--bg-hover);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.admin-stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.admin-stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.admin-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.admin-table tr:hover td { background: var(--bg-hover); }
.admin-actions { white-space: nowrap; }
.admin-actions form { margin-left: 4px; }

/* ===== Notifications ===== */
.notification-list { }
.notification-item {
    display: flex;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    transition: background .15s;
}
.notification-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.notification-item.unread { background: var(--primary-light); }
.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}
.notif-content { flex: 1; min-width: 0; }
.notif-text { font-size: 14px; line-height: 1.4; }
.notif-post { font-size: 13px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: 12px; color: var(--text-muted); }

/* ===== Moderator list ===== */
.mod-list { list-style: none; }
.mod-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}
.site-footer .footer-text { margin: 0; }
.site-footer .footer-socials {
    display: flex; justify-content: center; gap: 16px;
    list-style: none; padding: 0; margin: 12px 0 0;
}
.site-footer .footer-socials a {
    color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    transition: color .15s, background .15s;
}
.site-footer .footer-socials a:hover { color: var(--primary); background: var(--bg-hover); }
.nav-brand-logo { height: 32px; max-width: 220px; object-fit: contain; display: block; }

/* ===== Text utilities ===== */
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }

/* ===== Responsive ===== */
@media (max-width: 968px) {
    .sidebar { display: none; }
    .container { flex-direction: column; }
    .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* The mobile-only search trigger and close button are hidden on desktop;
   the always-visible .nav-search input handles search there. */
.nav-search-trigger { display: none; }
.nav-search-close { display: none; }

@media (max-width: 768px) {
    .mobile-menu-btn { display: flex; }
    .nav-search { display: none; }
    .nav-search-trigger { display: inline-flex; align-items: center; justify-content: center; }
    /* Mobile overlay: when .is-mobile-open is set on .nav-search (by the
       trigger button), it lifts out of the nav and covers the whole viewport
       with a stacked input + dropdown. */
    .nav-search.is-mobile-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 300;
        max-width: none;
        background: var(--bg, #0c1024);
        padding: 14px 16px;
        overflow-y: auto;
    }
    .nav-search.is-mobile-open .search-form { position: relative; }
    .nav-search.is-mobile-open .search-input {
        background: var(--bg-input, rgba(255,255,255,.08));
        color: var(--text);
        font-size: 16px;
        padding: 12px 44px 12px 42px;
    }
    .nav-search.is-mobile-open .search-input::placeholder { color: var(--text-muted); }
    .nav-search.is-mobile-open .search-clear { background: var(--bg-input, rgba(0,0,0,.08)); color: var(--text); }
    .nav-search.is-mobile-open .search-dropdown {
        position: static;
        margin-top: 12px;
        border: none;
        background: transparent;
        box-shadow: none;
        max-height: none;
    }
    .nav-search.is-mobile-open .nav-search-close {
        display: inline-flex;
        position: absolute;
        top: 18px; right: 12px;
        width: 36px; height: 36px;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text);
        cursor: pointer;
        border-radius: 8px;
    }
    .nav-search.is-mobile-open .nav-search-close:hover { background: var(--bg-input, rgba(0,0,0,.06)); }
    .nav-search.is-mobile-open .search-form { margin-right: 40px; }
    .nav-username { display: none; }
    .nav-create-btn span { display: none; }
    .community-banner { height: 120px; }
    .community-title { font-size: 18px; }
    .community-icon-lg { width: 48px; height: 48px; font-size: 18px; }
    .post-card { }
    .vote-controls { padding: 8px 4px; min-width: 40px; }
    .post-title { font-size: 15px; }
    .post-detail-title { font-size: 18px; }
    .post-content { padding: 10px 12px; }
    .comment-thread[data-depth="0"] { padding: 6px 8px 4px 4px !important; }
    .thread-line-area { width: 16px !important; min-width: 16px !important; }
    .thread-line-area .collapse-toggle { width: 14px !important; height: 14px !important; min-width: 14px !important; font-size: 10px !important; }
    .comment-thread:not([data-depth="0"]) { padding: 2px 0 !important; }
    .form-row { grid-template-columns: 1fr; }
    .user-stats { gap: 16px; }
    .auth-container { margin: 20px auto; }
    .container { padding: 12px 10px; }
}

@media (max-width: 480px) {
    .nav-inner { padding: 0 10px; gap: 8px; }
    .nav-brand { font-size: 17px; }
    .sort-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sort-tab { padding: 8px 12px; font-size: 13px; white-space: nowrap; }
    .btn-sm { padding: 5px 10px; font-size: 12px; }
    .admin-stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .admin-stat-value { font-size: 22px; }
    .post-actions { flex-wrap: wrap; }
}

/* ===== Smooth transitions ===== */
.post-card, .card, .sidebar-card, .btn, .sort-tab, .dropdown-menu,
.notification-item, .comment-thread, .vote-btn, .vote-btn-inline {
    transition-duration: 0.15s;
    transition-timing-function: ease;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Search page ===== */
.search-page-form .form-input { border-radius: 24px; }

/* ===== Avatars ===== */
.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.avatar-sm {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.avatar-lg {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-card);
    border: 4px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}
.post-meta-avatar-wrap {
    display: inline-block;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    border-radius: 50%;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 2px;
    flex-shrink: 0;
    position: relative;
}
.post-meta-avatar-wrap img {
    width: 18px;
    height: 18px;
    max-width: 18px;
    max-height: 18px;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}
.comment-avatar {
    width: 22px;
    height: 22px;
    max-width: 22px;
    max-height: 22px;
    min-width: 22px;
    min-height: 22px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.comment-avatar-placeholder {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    border-radius: 50%;
    overflow: hidden;
    vertical-align: middle;
    flex-shrink: 0;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
}

/* ===== Avatar settings ===== */
.avatar-settings {
    display: flex;
    align-items: center;
    gap: 20px;
}
.avatar-preview {
    flex-shrink: 0;
}
.avatar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.avatar-file-label {
    cursor: pointer;
}

/* Avatar crop modal */
.avatar-crop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.avatar-crop-modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.avatar-crop-modal h3 {
    margin-bottom: 16px;
    font-size: 18px;
}
.avatar-crop-area {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 16px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary);
    cursor: grab;
    background: var(--bg-input);
    touch-action: none;
}
.avatar-crop-area:active { cursor: grabbing; }
.avatar-crop-area img {
    position: absolute;
    max-width: none;
    max-height: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}
.avatar-crop-zoom {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 0 10px;
}
.avatar-crop-zoom label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.avatar-crop-zoom input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}
.avatar-crop-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ===== Joined communities sidebar ===== */
.community-list-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.community-list-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/* Two-column page layout — used by the homepage and any custom page that
   picks the "sidebar" layout. Lives in the global stylesheet so /<slug>
   pages can reuse it without inlining the rules. */
.blog-home { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }
@media (max-width: 1000px) { .blog-home { grid-template-columns: 1fr; } }
.blog-sidebar > * + * { margin-top: 24px; }
.sidebar-widget { background: var(--bg-card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 16px 18px; }
.sidebar-widget h4 { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); margin: 0 0 12px; }
.sidebar-widget ul { list-style: none; margin: 0; padding: 0; }
.sidebar-widget ul li + li { margin-top: 8px; }
.sidebar-widget ul a { color: var(--text); text-decoration: none; font-size: 14px; }
.sidebar-widget ul a:hover { color: var(--primary); }
.sidebar-widget .meta-line { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.sidebar-cta { background: linear-gradient(135deg, var(--primary), #8B5CF6); color: #fff; border: none; }
.sidebar-cta h4 { color: rgba(255,255,255,.85); }
.sidebar-cta p { font-size: 14px; margin: 0 0 12px; line-height: 1.45; }
.sidebar-cta .btn { background: #fff; color: var(--primary); }

/* ===== Hero (featured article) layout variants ===== */
/* Single typography system: bold sans throughout, weight + size + tracking
   create the editorial feel. No serifs — keeps the brand consistent. */

/* Shared meta row (used by every variant). Compact, low-emphasis. */
.featured-meta-center { justify-content: center; text-align: center; }

/* Shared headline reset — every variant overrides size/weight from here. */
.fa-newspaper-headline a, .fa-magazine-headline a, .fa-highlight-headline a, .fa-media-link { color: inherit; text-decoration: none; }
.fa-newspaper-headline a:hover, .fa-magazine-headline a:hover, .fa-highlight-headline a:hover { color: var(--primary); }

/* Shared eyebrow tag — used as the kicker above each headline. */
.home-widget-featured .featured-tag { display: inline-block; background: var(--primary-light, rgba(99,102,241,.1)); color: var(--primary); padding: 4px 12px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 14px; }

/* --- Variant: Newspaper --- heavy headline + meta-line above small image */
.fa-newspaper { padding: 24px 28px; background: var(--bg-card,#fff); border: 1px solid var(--border,#e5e7eb); border-radius: 16px; margin-bottom: 32px; }
.fa-newspaper-headline { font-size: clamp(30px, 4.4vw, 52px); line-height: 1.05; font-weight: 900; letter-spacing: -0.025em; margin: 0 0 14px; }
.fa-newspaper .featured-excerpt { font-size: 17px; line-height: 1.55; color: var(--text-secondary); margin: 0 0 18px; max-width: 720px; }
.fa-newspaper-image { display: block; margin: 0 0 18px; }
.fa-newspaper-image img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; max-height: 360px; }

/* --- Variant: Magazine --- image on top, centered headline below --- */
.fa-magazine { padding: 0 0 24px; background: var(--bg-card,#fff); border: 1px solid var(--border,#e5e7eb); border-radius: 16px; margin-bottom: 32px; overflow: hidden; }
.fa-magazine-image { display: block; }
.fa-magazine-image img { width: 100%; aspect-ratio: 21/9; object-fit: cover; display: block; max-height: 420px; }
.fa-magazine-content { padding: 26px 28px 8px; text-align: center; max-width: 760px; margin: 0 auto; }
.fa-magazine-headline { font-size: clamp(28px, 3.8vw, 44px); line-height: 1.1; font-weight: 900; letter-spacing: -0.02em; margin: 0 0 14px; }
.fa-magazine-content .featured-excerpt { font-size: 16px; line-height: 1.55; color: var(--text-secondary); margin: 0 0 18px; }

/* --- Variant: Media feature --- full-bleed image w/ ambient halo + bottom overlay --- */
/* The halo is the trick: a ::before pseudo-element copies the hero image,
   scales 40px past the visible bounds, and applies a 60px blur with mild
   saturation. The image appears to "glow into" the page background. */
.fa-media {
    position: relative;
    isolation: isolate;
    border-radius: 18px;
    height: var(--media-height, 520px);
    margin-bottom: 32px;
}
.fa-media::before {
    content: '';
    position: absolute;
    inset: -40px;
    background: var(--hero-bg) center/cover no-repeat;
    filter: blur(60px) saturate(1.35);
    opacity: 0.55;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
}
.fa-media-link {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    color: #fff;
}
.fa-media-image { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.fa-media-placeholder { background: linear-gradient(135deg, var(--primary), #8B5CF6); }
.fa-media-overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 32px 36px 30px;
    background: linear-gradient(to top, rgba(8,12,24,0.95) 0%, rgba(8,12,24,0.65) 45%, rgba(8,12,24,0) 100%);
}
.fa-media-headline {
    font-size: clamp(26px, 3.4vw, 44px);
    line-height: 1.1;
    font-weight: 900;
    letter-spacing: -0.025em;
    margin: 0 0 12px;
    color: #fff;
    max-width: 760px;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.fa-media-excerpt {
    font-size: 15px;
    line-height: 1.5;
    color: rgba(255,255,255,.88);
    margin: 0 0 18px;
    max-width: 640px;
    /* Hard cap at 2 lines so a long excerpt (when the article has no
       subtitle to fall back on) can't push the CTA off the hero. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.fa-media-cta { display: inline-flex; align-items: center; gap: 12px; }
.fa-media-cta-icon {
    width: 38px; height: 38px;
    background: #fff;
    color: #0f172a;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .2s, background .2s;
}
.fa-media-link:hover .fa-media-cta-icon { transform: translateX(3px); background: var(--primary); color: #fff; }
.fa-media-cta-label {
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .14em;
}

/* ===== Fit mode =====
   Image anchored right at natural aspect (object-fit: contain), the rest of
   the card filled with a blurred scaled-up copy of the image so there's no
   hard letterbox. Text overlay moves to the left with a right-fading
   gradient. The article's `::before` halo still bleeds outside (kept for
   continuity with the fill mode); the new `::before` on `.fa-media-link`
   provides the in-card blurred backdrop. */
.fa-media-fit .fa-media-link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--hero-bg) center/cover no-repeat;
    filter: blur(40px) saturate(1.2);
    transform: scale(1.15);
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
}
.fa-media-fit .fa-media-image,
.fa-media-fit .fa-media-overlay {
    position: relative;
    z-index: 1;
}
.fa-media-fit .fa-media-image {
    /* Sizing: height fills, width derived from natural aspect — so the IMG
       element box matches the visible image pixels exactly (no internal
       letterbox). Anchored to the right via absolute positioning. For very
       wide images, max-width clamps the box to the container width, which
       reduces height proportionally; the resulting empty band sits over the
       blurred bg, so it looks fine. */
    position: absolute;
    top: 0; right: 0;
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: initial;
    /* Soft horizontal fade on the leftmost ~30% of the visible image. The
       mask makes the image's left edge gradually transparent, letting the
       blurred backdrop bleed through — so the hard edge dissolves instead
       of cutting hard against the bg. */
    -webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.4) 14%, #000 32%);
            mask-image: linear-gradient(to right, transparent 0%, rgba(0,0,0,0.4) 14%, #000 32%);
}
.fa-media-fit .fa-media-overlay {
    position: absolute;
    inset: 0 auto 0 0;
    width: clamp(320px, 48%, 620px);
    padding: 0 36px;
    background: linear-gradient(to right, rgba(8,12,24,0.85) 0%, rgba(8,12,24,0.55) 70%, rgba(8,12,24,0) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.fa-media-fit .fa-media-headline { margin-bottom: 14px; max-width: none; }
.fa-media-fit .fa-media-excerpt { max-width: none; }

@media (max-width: 900px) {
    .fa-media-fit .fa-media-overlay { width: 60%; padding: 0 24px; }
}

/* ===== Hero rotator =====
   Holds N pre-rendered hero variants stacked on top of each other. Only the
   .is-active slide is opaque; the rest sit underneath at opacity 0 so the
   container's height comes from the active slide. JS toggles the class on
   an interval; CSS handles the crossfade. */
/* Hero rotator: stage on top, dots row below. Hero stays full-width.
   Manual navigation is dot-only — auto-rotate handles the passive case. */
.hero-rotator { position: relative; }
.hero-rotator-stage { position: relative; }
.hero-rotator-stage > .hero-rotator-slide { transition: opacity 600ms ease; }
.hero-rotator-stage > .hero-rotator-slide:not(.is-active) {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}
.hero-rotator-stage > .hero-rotator-slide.is-active {
    position: relative;
    opacity: 1;
}
.hero-rotator-stage > .hero-rotator-slide > .home-widget-featured { margin-bottom: 0; }

/* Dot indicators — row of small circles below the stage. Active dot is
   wider (pill-style) to give a clear sense of position. */
.hero-rotator-dots {
    display: flex;
    justify-content: center;
    gap: 7px;
    padding: 14px 0 4px;
}
.hero-rotator-dot {
    appearance: none;
    background: var(--text-muted, #94a3b8);
    border: none;
    width: 7px;
    height: 7px;
    padding: 0;
    border-radius: 999px;
    cursor: pointer;
    opacity: .35;
    transition: opacity .15s, width .2s ease, background .15s;
}
.hero-rotator-dot:hover { opacity: .7; }
.hero-rotator-dot.is-active {
    width: 22px;
    opacity: 1;
    background: var(--primary);
}


/* Tablet: respect the slider but cap to viewport so a tall slider value
   (e.g. 800px) doesn't dominate the screen. */
@media (max-width: 1000px) {
    .fa-media { height: min(var(--media-height, 520px), 70vh); }
}

/* Mobile: scale slider down + clamp so the hero stays a reasonable height
   even with a tall desktop value. The clamp keeps it ≥260px (still feels
   like a hero) and ≤55vh (never more than half the viewport). */
@media (max-width: 700px) {
    .fa-media { height: clamp(260px, calc(var(--media-height, 520px) * 0.65), 55vh); aspect-ratio: auto; }
    .fa-media-overlay { padding: 22px 20px 22px; }
    .fa-media-excerpt { display: none; }
    /* On mobile the fit-mode overlay reverts to the bottom strip — there's
       no horizontal room to split image and text side by side. */
    .fa-media-fit .fa-media-overlay {
        position: absolute;
        inset: auto 0 0 0;
        width: 100%;
        padding: 22px 20px;
        background: linear-gradient(to top, rgba(8,12,24,0.95) 0%, rgba(8,12,24,0.65) 45%, rgba(8,12,24,0) 100%);
    }
    .fa-media-fit .fa-media-image {
        position: static;
        width: 100%;
        height: 100%;
        max-width: 100%;
        object-fit: cover;
        object-position: center;
        -webkit-mask-image: none;
                mask-image: none;
    }
}

/* ===== Newsroom variant: 5-up front-page grid =====
   Layout: 1fr 1.7fr 1fr — two stacked side cards on each flank, dominant
   feature in the middle. The side cards stack vertically and equally split
   their column. On narrow screens we collapse to a single column and the
   sides become a 2x2 grid below the main feature. */
.fa-newsroom {
    display: grid;
    grid-template-columns: 1fr 1.7fr 1fr;
    gap: 28px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 32px;
}
.fa-newsroom-side {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 24px;
    min-width: 0;
}
.fa-newsroom-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.fa-newsroom-main-img { display: block; border-radius: 12px; overflow: hidden; }
.fa-newsroom-main-img img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.fa-newsroom-main-img-placeholder { display: block; width: 100%; aspect-ratio: 16/10; background: linear-gradient(135deg, var(--primary), #8B5CF6); }
.fa-newsroom-main-body { display: flex; flex-direction: column; gap: 12px; padding: 0 6px; }
.fa-newsroom-main .featured-tag { align-self: flex-start; }
.fa-newsroom-main-title { font-size: clamp(24px, 2.6vw, 34px); line-height: 1.15; letter-spacing: -0.015em; font-weight: 800; margin: 0; }
.fa-newsroom-main-title a { color: inherit; text-decoration: none; }
.fa-newsroom-main-title a:hover { color: var(--primary); }
.fa-newsroom-main-excerpt { font-size: 16px; line-height: 1.55; color: var(--text-secondary); margin: 0; }

.fa-newsroom-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fa-newsroom-card-img { display: block; border-radius: 10px; overflow: hidden; }
.fa-newsroom-card-img img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.fa-newsroom-card-img-placeholder { display: block; width: 100%; aspect-ratio: 16/10; background: linear-gradient(135deg, var(--primary), #8B5CF6); }
.fa-newsroom-card-title { font-size: 16px; line-height: 1.25; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.fa-newsroom-card-title a { color: inherit; text-decoration: none; }
.fa-newsroom-card-title a:hover { color: var(--primary); }
.fa-newsroom-card-excerpt { font-size: 13px; line-height: 1.5; color: var(--text-secondary); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fa-newsroom-card-meta { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--text-muted, var(--text-secondary)); display: inline-flex; align-items: center; gap: 6px; }
.fa-newsroom-card-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .55; display: inline-block; }

@media (max-width: 1100px) {
    .fa-newsroom { grid-template-columns: 1fr; }
    .fa-newsroom-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .fa-newsroom-side { grid-template-columns: 1fr; }
}

/* Fullbleed adaptation — strip the card chrome but keep image radii rounded. */
body.container-fullbleed .fa-newsroom { background: transparent; border: none; border-radius: 0; padding: 0; }

/* ===== Container style: full-bleed mode =====
   When body.container-fullbleed is set (admin opt-in), strip the bubble
   chrome (backgrounds, borders, rounded corners) from cards on the home
   page. Hairlines + spacing do the visual work instead. Image radii are
   preserved — only the surrounding container loses its chrome. */
body.container-fullbleed .article-card,
body.container-fullbleed .sidebar-widget:not(.sidebar-cta),
body.container-fullbleed .fa-newspaper,
body.container-fullbleed .fa-magazine,
body.container-fullbleed .fa-highlight {
    background: transparent;
    border: none;
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
    box-shadow: none;
}
body.container-fullbleed .fa-magazine { padding-bottom: 0; }
body.container-fullbleed .fa-magazine-image img { border-radius: 12px; }
body.container-fullbleed .fa-magazine-content { padding-left: 0; padding-right: 0; padding-top: 22px; }
body.container-fullbleed .article-card .card-image { border-radius: 12px; overflow: hidden; }
body.container-fullbleed .article-card { padding-bottom: 28px; border-bottom: 1px solid var(--border, #e5e7eb); border-radius: 0; }
body.container-fullbleed .article-card:hover { transform: none; box-shadow: none; }
body.container-fullbleed .article-card .card-content { padding-left: 0; padding-right: 0; padding-top: 14px; }
body.container-fullbleed .article-grid { gap: 32px 28px; }
/* Sidebar cards: hairline divider between them instead of card chrome.
   The sidebar-cta (newsletter signup) keeps its gradient bubble — it's a
   call-to-action and benefits from standing out. */
body.container-fullbleed .blog-sidebar .sidebar-widget { padding: 0 0 20px; border-bottom: 1px solid var(--border, #e5e7eb); }
body.container-fullbleed .blog-sidebar .sidebar-widget:last-child { border-bottom: none; padding-bottom: 0; }
body.container-fullbleed .blog-sidebar > * + * { margin-top: 24px; }
/* Fullbleed sharpens hero corners — minimal radius, keeps the halo clean. */
body.container-fullbleed .fa-media { border-radius: 6px; }
body.container-fullbleed .fa-media-link,
body.container-fullbleed .fa-media-image,
body.container-fullbleed .fa-media-overlay { border-radius: inherit; }
/* Slightly tighter latest grid in fullbleed mode — image radii stay rounded
   while the surrounding card chrome is gone. Vertical rhythm comes from gap +
   hairline below each row. */
body.container-fullbleed .article-grid { gap: 36px 28px; }
body.container-fullbleed .article-card .card-image { border-radius: 8px; aspect-ratio: 16/9; }

/* "Most Popular" sub-row — a horizontal strip of 4 compact cards. Sits
   directly under the hero. Same 1200px container width when full-bleed,
   inside the main column otherwise. Layout: small thumb (right) + title +
   date (left). */
.hero-top-posts { margin-top: 24px; }
.hero-top-posts .htp-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; padding: 0 4px; }
.hero-top-posts .htp-eyebrow { font-size: 13px; font-weight: 800; color: var(--text); }
.hero-top-posts .htp-viewall { font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--text-secondary); text-decoration: none; }
.hero-top-posts .htp-viewall:hover { color: var(--primary); }
.hero-top-posts .htp-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1000px) { .hero-top-posts .htp-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .hero-top-posts .htp-row { grid-template-columns: 1fr; } }
.hero-top-posts .htp-card {
    display: flex; gap: 12px; align-items: flex-start;
    text-decoration: none; color: var(--text);
    padding: 4px;
    border-radius: 6px;
    transition: background .15s;
}
.hero-top-posts .htp-card:hover { background: var(--bg-input, rgba(0,0,0,.03)); }
.hero-top-posts .htp-thumb {
    flex-shrink: 0;
    width: 56px; height: 56px;
    object-fit: cover;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
}
.hero-top-posts .htp-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hero-top-posts .htp-title { font-size: 13px; line-height: 1.3; font-weight: 700; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-top-posts .htp-date { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--text-muted, #94a3b8); }

/* When the hero is INSIDE the main column (not full-bleed), the row sits
   inside the same column. Tighten spacing accordingly. */
.blog-home .hero-top-posts { margin-top: 18px; margin-bottom: 28px; }
.blog-home .hero-top-posts .htp-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .blog-home .hero-top-posts .htp-row { grid-template-columns: 1fr; } }

/* In bubble mode, wrap the most-popular row in a card so it visually attaches
   to the hero — Substack's idiom. */
body.container-bubble .hero-top-posts {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 16px;
    padding: 16px 20px;
}
body.container-bubble .hero-full-bleed .hero-top-posts { margin-top: 16px; }

/* --- Hero width: full vs with-sidebar ---
   Full-width hero breaks out of the 2-col grid: rendered above .blog-home
   in its own container that matches the same max-width but spans
   end-to-end (no sidebar gutter). */
.hero-full-bleed {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 0;
}
.hero-full-bleed .home-widget-featured { margin-bottom: 0; }
@media (min-width: 1001px) {
    .hero-full-bleed + .blog-home { padding-top: 32px; }
}

/* --- Variant: Highlight --- editorial pull-quote with square thumb --- */
.fa-highlight { display: grid; grid-template-columns: 160px 1fr; gap: 24px; align-items: center; padding: 24px 28px; background: var(--bg-card,#fff); border: 1px solid var(--border,#e5e7eb); border-radius: 16px; margin-bottom: 32px; }
@media (max-width: 600px) { .fa-highlight { grid-template-columns: 1fr; gap: 16px; } }
.fa-highlight-thumb { display: block; }
.fa-highlight-thumb img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 10px; }
.fa-highlight-headline { font-size: clamp(22px, 2.8vw, 34px); line-height: 1.2; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 12px; }
.fa-highlight .featured-excerpt { font-size: 15px; line-height: 1.55; color: var(--text-secondary); margin: 0 0 12px; }

/* ===== Latest articles — List variant (image-left rows) ===== */
.la-list .la-list-rows { display: flex; flex-direction: column; gap: 24px; }
.la-list-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 700px) { .la-list-row { grid-template-columns: 120px 1fr; gap: 16px; } }
@media (max-width: 480px) { .la-list-row { grid-template-columns: 1fr; } }
.la-list-thumb { display: block; }
.la-list-thumb img,
.la-list-thumb-placeholder {
    width: 100%; aspect-ratio: 4/3;
    object-fit: cover; display: block;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
}
.la-list-title { font-size: clamp(18px, 2.2vw, 24px); line-height: 1.2; font-weight: 800; letter-spacing: -0.005em; margin: 8px 0 8px; }
.la-list-title a { color: var(--text); text-decoration: none; }
.la-list-title a:hover { color: var(--primary); }
.la-list-excerpt { font-size: 14px; line-height: 1.55; color: var(--text-secondary); margin: 0 0 10px; }
.la-list-body .card-tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin-bottom: 4px; }

/* In bubble mode the list rows hairline below for separation. */
body.container-bubble .la-list-row { padding-bottom: 24px; border-bottom: 1px solid var(--border); }
body.container-bubble .la-list-row:last-child { border-bottom: none; padding-bottom: 0; }
/* Fullbleed mode: tighter, image radius reduced. */
body.container-fullbleed .la-list-thumb img { border-radius: 6px; }

/* ===== Latest articles — Compact variant (title + date list) ===== */
.la-compact-list { list-style: none; margin: 0; padding: 0; }
.la-compact-row { border-bottom: 1px solid var(--border); }
.la-compact-row:first-child { border-top: 1px solid var(--border); }
.la-compact-link {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    gap: 16px; align-items: center;
    padding: 14px 4px;
    text-decoration: none;
    color: var(--text);
    transition: background .12s;
}
.la-compact-link:hover { background: var(--bg-input, rgba(0,0,0,.02)); }
@media (max-width: 600px) { .la-compact-link { grid-template-columns: 60px 1fr; } .la-compact-author { display: none; } }
.la-compact-date { font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--text-muted); }
.la-compact-title { font-size: 16px; font-weight: 700; line-height: 1.3; }
.la-compact-author { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.la-compact-link:hover .la-compact-title { color: var(--primary); }

/* ===== Latest_articles variant: Tabbed feed =====
   Pill tabs (Latest/Top/Deals/Discussions) over a list of rows. Image on
   the right (~280px), title + excerpt + meta on the left, hairline divider
   between rows. Time-window selector appears beneath the tabs for every
   tab except "Latest". */
.la-tabbed { padding: 0; }
.la-tabbed .ltf-tabbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.la-tabbed .ltf-tabs {
    display: inline-flex;
    background: var(--bg-input, rgba(255,255,255,.04));
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px;
    gap: 2px;
}
.la-tabbed .ltf-tab {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    padding: 7px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, color .15s;
    font-family: inherit;
}
.la-tabbed .ltf-tab:hover { color: var(--text); }
.la-tabbed .ltf-tab.is-active {
    background: var(--bg-card, rgba(255,255,255,.06));
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.la-tabbed .ltf-windows { display: inline-flex; gap: 4px; }
.la-tabbed .ltf-footer {
    display: flex;
    justify-content: flex-end;
    padding: 14px 0 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
.la-tabbed .ltf-viewall {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 4px;
    transition: color .15s;
}
.la-tabbed .ltf-viewall:hover { color: var(--primary); }
.la-tabbed .ltf-win {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: color .15s, background .15s, border-color .15s;
}
.la-tabbed .ltf-win:hover { color: var(--text); }
.la-tabbed .ltf-win.is-active { color: var(--primary); border-color: var(--primary); background: rgba(99,102,241,.08); }
.la-tabbed .ltf-rows { display: flex; flex-direction: column; }
.la-tabbed .ltf-rows.is-loading { opacity: .55; transition: opacity .15s; }
.la-tabbed .ltf-row {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 22px;
    align-items: start;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}
.la-tabbed .ltf-row:first-child { padding-top: 4px; }
.la-tabbed .ltf-row:last-child { border-bottom: none; }
.la-tabbed .ltf-row-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.la-tabbed .ltf-row-title { font-size: clamp(18px, 1.6vw, 22px); line-height: 1.25; font-weight: 800; letter-spacing: -0.015em; margin: 0; }
.la-tabbed .ltf-row-title a { color: inherit; text-decoration: none; }
.la-tabbed .ltf-row-title a:hover { color: var(--primary); }
.la-tabbed .ltf-row-excerpt { font-size: 14px; line-height: 1.45; color: var(--text-secondary); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.la-tabbed .ltf-row-meta { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--text-muted); display: inline-flex; align-items: center; gap: 8px; margin-top: 2px; }
.la-tabbed .ltf-dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .55; display: inline-block; }
.la-tabbed .ltf-price { color: var(--primary); }
.la-tabbed .ltf-row-img { display: block; border-radius: 10px; overflow: hidden; }
.la-tabbed .ltf-row-img img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }

/* First row of the feed gets a hero treatment: full-width image on top,
   larger title + excerpt below. Subsequent rows stay compact. */
.la-tabbed .ltf-row-hero {
    display: block;
    grid-template-columns: none;
    padding: 0 0 24px;
}
.la-tabbed .ltf-row-hero .ltf-hero-img { display: block; border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.la-tabbed .ltf-row-hero .ltf-hero-img img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.la-tabbed .ltf-row-hero .ltf-row-title { font-size: clamp(24px, 2.4vw, 32px); line-height: 1.15; }
.la-tabbed .ltf-row-hero .ltf-row-excerpt { font-size: 15px; -webkit-line-clamp: 3; }
.la-tabbed .ltf-empty { padding: 40px 0; text-align: center; color: var(--text-muted); font-size: 14px; }
/* Deals & discussions tabs: stack the existing cards vertically with the
   same spacing the dedicated pages use, so the layout matches what the
   user sees on /deals and inside a community. */
.la-tabbed .ltf-deals,
.la-tabbed .ltf-discussions { display: flex; flex-direction: column; gap: 12px; }

/* /articles index page — the same tabbed feed component, with infinite-scroll
   pagination chrome (sentinel + "you're all caught up" footer). The tabbed
   component renders deal/article/discussion rows the same way it does on
   the homepage; only the surrounding shell changes. */
.articles-page { max-width: 920px; margin: 0 auto; padding: 24px 0 60px; }
.articles-page-header { margin-bottom: 24px; }
.articles-page-header h1 { font-size: clamp(28px, 3vw, 40px); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
.articles-page-subtitle { color: var(--text-secondary); font-size: 15px; margin: 0; }
.la-tabbed-page .ltf-tab,
.la-tabbed-page .ltf-win { text-decoration: none; }
.ltf-loadmore {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 28px 0;
    color: var(--text-muted);
    font-size: 13px; font-weight: 600;
}
.ltf-loadmore-spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ltf-spin .8s linear infinite;
}
@keyframes ltf-spin { to { transform: rotate(360deg); } }
.ltf-end { padding: 28px 0; text-align: center; color: var(--text-muted); font-size: 13px; font-weight: 600; }

@media (max-width: 700px) {
    .la-tabbed .ltf-row { grid-template-columns: 1fr; gap: 14px; }
    .la-tabbed .ltf-row-img { order: -1; max-width: 100%; }
    .la-tabbed .ltf-row-img img { aspect-ratio: 16/9; }
    .la-tabbed .ltf-tabs { width: 100%; overflow-x: auto; }
    .la-tabbed .ltf-tabbar { gap: 8px; }
}

/* ===== Edit-in-place overlay editor ===== */

/* Floating "Edit page" pill — admin-only, default state on supported pages. */
.editor-pill {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 200;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    background: #0f172a; color: #fff;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 999px;
    text-decoration: none;
    font-size: 13px; font-weight: 700;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    transition: transform .12s, background .12s;
}
.editor-pill:hover { transform: translateY(-2px); background: var(--primary, #6366F1); color: #fff; }
.editor-pill svg { display: block; }

/* Top toolbar shown when in edit mode. */
.editor-toolbar {
    position: sticky; top: 0; z-index: 150;
    display: flex; align-items: center; gap: 16px;
    padding: 10px 24px;
    background: #0f172a; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    font-size: 13px;
}
.editor-toolbar-title { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.editor-toolbar-dot { width: 8px; height: 8px; border-radius: 50%; background: #FFC842; box-shadow: 0 0 0 4px rgba(255,200,66,.18); animation: edDotPulse 2s ease-in-out infinite; }
@keyframes edDotPulse { 50% { box-shadow: 0 0 0 6px rgba(255,200,66,.05); } }
.editor-toolbar-hint { color: rgba(255,255,255,.6); font-size: 12px; }
.editor-toolbar-exit { margin-left: auto; color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-weight: 700; transition: background .12s; }
.editor-toolbar-exit:hover { background: rgba(255,255,255,.08); }

/* Section overlays — yellow outline on hover and when active. The label
   appears in the top-left corner. Uses a wrapper element so the page
   layout isn't disturbed when not in edit mode. */
main.is-editing [data-editable] {
    position: relative;
    cursor: pointer;
    transition: box-shadow .15s;
}
main.is-editing [data-editable]:hover,
main.is-editing [data-editable].is-editing-active {
    box-shadow: 0 0 0 3px #FFC842, 0 8px 24px rgba(0,0,0,.12);
    border-radius: 10px;
}
main.is-editing [data-editable]::before {
    content: attr(data-section-label);
    position: absolute; top: 8px; left: 8px;
    padding: 3px 10px;
    background: #FFC842; color: #0f172a;
    font-size: 11px; font-weight: 800;
    letter-spacing: .08em; text-transform: uppercase;
    border-radius: 6px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s;
}
main.is-editing [data-editable]:hover::before,
main.is-editing [data-editable].is-editing-active::before { opacity: 1; }

/* "Site theme" pill — anchored bottom-left in edit mode, opens the theme
   panel directly (sections aren't clickable for site-wide settings). */
.ed-theme-pill {
    position: fixed;
    bottom: 24px; left: 24px;
    z-index: 200;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px;
    background: #fff; color: #0f172a;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px; font-weight: 700; font-family: inherit;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
    transition: transform .12s;
}
.ed-theme-pill:hover { transform: translateY(-2px); }

/* Right-side drawer — slides in. Backdrop dims the page. */
.ed-drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .35);
    z-index: 250;
    opacity: 0;
    transition: opacity .2s;
}
.ed-drawer-backdrop.is-open { opacity: 1; }
.ed-drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 260;
    width: 380px; max-width: 92vw;
    background: var(--bg-card, #fff);
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 30px rgba(0,0,0,.18);
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .22s ease;
}
.ed-drawer.is-open { transform: translateX(0); }
.ed-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.ed-drawer-head h2 { margin: 0; font-size: 17px; font-weight: 800; }
.ed-drawer-close { background: transparent; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.ed-drawer-close:hover { background: var(--bg-input); color: var(--text); }
.ed-drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.ed-drawer-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; gap: 10px; justify-content: flex-end;
    background: var(--bg-card);
}

/* Panel visibility: only the panel matching the clicked section shows.
   Use a class instead of the [hidden] attribute because .ed-panel has
   display: flex which would otherwise override [hidden]'s display: none. */
.ed-panel { display: none; flex-direction: column; gap: 16px; }
.ed-panel.is-active { display: flex; }
.ed-field { display: flex; flex-direction: column; gap: 6px; }
.ed-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }
.ed-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit; }
.ed-input:focus { outline: none; border-color: var(--primary); }
.ed-hint { font-size: 12px; color: var(--text-muted); line-height: 1.45; font-style: italic; }
.ed-radio-row { display: flex; gap: 8px; }
.ed-radio { flex: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; transition: border-color .12s, background .12s; }
.ed-radio:has(input:checked) { border-color: var(--primary); background: var(--primary-light, rgba(99,102,241,.06)); }
.ed-radio input { accent-color: var(--primary); }

.ed-toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.ed-toggle input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.ed-toggle-track { position: relative; flex-shrink: 0; width: 36px; height: 20px; background: var(--border); border-radius: 999px; transition: background .15s; margin-top: 2px; }
.ed-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.ed-toggle input:checked ~ .ed-toggle-track { background: var(--primary); }
.ed-toggle input:checked ~ .ed-toggle-track .ed-toggle-thumb { transform: translateX(16px); }
.ed-toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ed-toggle-text strong { font-size: 13px; }
.ed-toggle-text small { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.ed-toggle.ed-toggle-compact { padding: 6px 0; gap: 10px; }
.ed-toggle.ed-toggle-compact + .ed-toggle.ed-toggle-compact { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 6px; }

.ed-slider { width: 100%; -webkit-appearance: none; appearance: none; height: 4px; background: var(--border); border-radius: 999px; outline: none; cursor: pointer; }
.ed-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; background: var(--primary); border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); cursor: grab; }
.ed-slider::-moz-range-thumb { width: 18px; height: 18px; background: var(--primary); border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); cursor: grab; }
.ed-slider-value { font-weight: 700; color: var(--primary); font-size: 12px; margin-left: 6px; }

.ed-widget-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ed-widget-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; cursor: grab; user-select: none; }
.ed-widget-item.is-dragging { opacity: 0.4; }
.ed-widget-item.ed-widget-off { opacity: 0.6; background: transparent; }
.ed-widget-item .ed-widget-name { flex: 1; font-size: 13px; font-weight: 600; }
.ed-widget-item .ed-widget-handle { color: var(--text-muted); font-size: 13px; cursor: grab; }
.ed-widget-item input[type="checkbox"] { accent-color: var(--primary); }

.ed-btn { padding: 8px 18px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; border: 1px solid var(--border); font-family: inherit; }
.ed-btn-ghost { background: transparent; color: var(--text); }
.ed-btn-ghost:hover { background: var(--bg-input); }
.ed-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.ed-btn-primary:hover { background: var(--primary-hover, var(--primary)); }
