:root {
    --bg: #f4f4f5;
    --card-bg: #ffffff;
    --border: #e2e2e5;
    --text: #1a1a1b;
    --text-muted: #6b6b6f;
    --accent: #ff5a1f;
    --accent-dark: #d9460f;
    --up: #ff5a1f;
    --down: #6a6af2;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
}
.logo { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.search-form { flex: 1; }
.search-form input {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
}
.header-nav { display: flex; gap: 14px; align-items: center; font-size: 0.92rem; }

.site-main { max-width: 1100px; margin: 0 auto; padding: 20px 16px; min-height: 70vh; }

.page-layout { display: flex; gap: 20px; align-items: flex-start; }
.feed-col { flex: 1; min-width: 0; }
.sidebar { width: 280px; flex-shrink: 0; }

.flash {
    background: #e6f7ec;
    border: 1px solid #b6e6c4;
    color: #1c6b34;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.error {
    background: #fdeceb;
    border: 1px solid #f3b8b3;
    color: #9b2c20;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.sort-tabs { display: flex; gap: 12px; margin-bottom: 14px; }
.sort-tabs a {
    padding: 6px 14px;
    border-radius: 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
}
.sort-tabs a.active { background: var(--accent); color: #fff; }

.post-card {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}
.vote-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    background: #fafafa;
    border-right: 1px solid var(--border);
    width: 44px;
    flex-shrink: 0;
}
.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    padding: 2px;
    line-height: 1;
}
.vote-btn:disabled { cursor: not-allowed; opacity: 0.4; }
.vote-btn.up.active { color: var(--up); }
.vote-btn.down.active { color: var(--down); }
.score { font-size: 0.85rem; font-weight: 700; margin: 2px 0; }

.post-body { padding: 10px 14px; flex: 1; min-width: 0; }
.post-meta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.community-link { font-weight: 700; color: var(--text); }
.post-title { font-size: 1.05rem; margin: 0 0 6px 0; }
.post-link-domain { font-size: 0.8rem; color: var(--text-muted); }
.post-image { max-width: 100%; max-height: 420px; border-radius: 6px; margin: 6px 0; }
.post-actions { font-size: 0.85rem; color: var(--text-muted); }
.post-full-body { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 14px; white-space: pre-wrap; }

.empty-state { color: var(--text-muted); padding: 30px 0; text-align: center; }

.sidebar-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
}
.sidebar-box h3 { margin-top: 0; }
.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 18px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    margin-top: 8px;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }

.auth-form-wrap {
    max-width: 420px;
    margin: 30px auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 600; }
.auth-form input, .auth-form textarea, .auth-form select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.community-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.community-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
}
.community-desc { margin: 2px 0 0; color: var(--text-muted); font-size: 0.85rem; }
.member-count { color: var(--text-muted); font-size: 0.85rem; }

.comments-section { margin-top: 20px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.comment-form textarea { padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.comment-list { display: flex; flex-direction: column; gap: 14px; }
.comment {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
}
.comment-meta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.comment-body { font-size: 0.92rem; white-space: pre-wrap; }
.comment-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; font-size: 0.8rem; }
.vote-col-inline { display: flex; align-items: center; gap: 4px; }
.vote-col-inline .vote-btn { font-size: 0.85rem; }
.reply-toggle { background: none; border: none; color: var(--text-muted); cursor: pointer; font-weight: 600; }
.reply-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.reply-form textarea { padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.comment-children { margin-left: 18px; margin-top: 10px; border-left: 2px solid var(--border); padding-left: 12px; }

.pagination { display: flex; justify-content: space-between; margin-top: 16px; }

.site-footer { text-align: center; color: var(--text-muted); font-size: 0.82rem; padding: 20px; }

@media (max-width: 700px) {
    .page-layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .header-nav { font-size: 0.8rem; gap: 8px; }
}
