* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --bg: #f5f5f5; --white: #fff; --text: #333; --text-light: #666; --text-lighter: #999; --border: #e5e5e5; --primary: #1b3668; --primary-hover: #254a8a; --accent: #e67e22; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; font-size: 15px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

/* HEADER */
header { background: var(--white); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px; }
.logo a { font-size: 24px; font-weight: 700; color: var(--primary); }
.search-box { flex: 1; max-width: 400px; }
.search-box form { display: flex; }
.search-box input { flex: 1; padding: 8px 14px; border: 1px solid #ccc; border-right: none; border-radius: 3px 0 0 3px; font-size: 14px; outline: none; }
.search-box input:focus { border-color: #999; }
.btn-search { padding: 8px 18px; background: var(--primary); color: #fff; border: none; border-radius: 0 3px 3px 0; cursor: pointer; font-size: 14px; }
.btn-search:hover { background: var(--primary-hover); }
.header-nav { display: flex; gap: 16px; font-size: 14px; margin-left: auto; }
.header-nav a { color: var(--text-light); }
.header-nav a:hover { color: var(--text); text-decoration: none; }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text); padding: 4px 8px; }

/* MOBILE MENU */
.mobile-menu { display: none; position: fixed; top: 52px; right: 16px; width: 220px; background: var(--white); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); z-index: 999; max-height: 60vh; overflow-y: auto; }
.mobile-menu.open { display: block; }
.mobile-menu-inner { padding: 6px 0; }
.mobile-menu-inner a { display: block; padding: 8px 16px; color: var(--text); font-size: 13px; border-radius: 0; }
.mobile-menu-inner a:hover { background: #f5f5f5; color: var(--primary); text-decoration: none; }
.mobile-menu-divider { height: 1px; background: var(--border); margin: 4px 12px; }

/* NAV */
.main-nav { background: var(--white); border-bottom: 2px solid var(--primary); }
.nav-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; }
.main-nav a { padding: 12px 20px; color: var(--text-light); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.main-nav a:hover { color: var(--text); text-decoration: none; }
.main-nav a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* LAYOUT */
.container { max-width: 1200px; margin: 0 auto; display: flex; background: var(--white); border: 1px solid var(--border); border-top: none; min-height: calc(100vh - 94px); }

/* SIDEBAR */
.sidebar { width: 300px; min-width: 300px; border-right: 1px solid var(--border); padding: 14px 0; position: sticky; top: 86px; height: calc(100vh - 86px); overflow-y: auto; }
.sidebar-title { font-size: 15px; font-weight: 600; color: var(--text); padding: 0 18px 10px; }
.topic-list { list-style: none; }
.topic-list li { padding: 6px 18px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.topic-list li:hover { background: #f8f8f8; }
.topic-list li a.topic-name { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-list li a.topic-name:hover { color: var(--primary); text-decoration: none; }
.topic-list li .topic-count { color: var(--text-lighter); font-size: 13px; min-width: 28px; text-align: right; padding-left: 8px; }

/* CONTENT */
.content { flex: 1; min-height: 100vh; }

/* TOPIC HEADER */
.topic-header { padding: 16px 28px; border-bottom: 1px solid var(--border); }
.topic-header h1 { font-size: 22px; font-weight: 700; color: var(--text); }

/* TOPIC ENTRY BLOCK */
.topic-entry-block { padding: 18px 28px; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.topic-entry-block:hover { background: #fafafa; }
.topic-entry-block a { pointer-events: none; }
.topic-entry-title { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.topic-entry-title a { color: var(--text); text-decoration: none; }
.topic-entry-title a:hover { color: var(--primary); }
.topic-entry-content { font-size: 16px; line-height: 1.8; color: #444; margin-bottom: 12px; }
.topic-entry-meta { font-size: 13px; color: var(--text-lighter); }
.topic-entry-meta .entry-author { color: var(--primary); font-weight: 500; font-size: 14px; }

/* ENTRY */
.entry { padding: 16px 28px; border-bottom: 1px solid #f0f0f0; }
.entry:hover { background: #fafafa; }
.entry-topic { margin-bottom: 6px; }
.entry-topic a { font-size: 13px; color: var(--primary); font-weight: 500; }
.entry-content { font-size: 16px; line-height: 1.8; color: #444; margin-bottom: 16px; white-space: pre-wrap; }
.entry-footer { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--text-lighter); }
.entry-author-info { display: flex; align-items: center; gap: 10px; }
.entry-author { color: var(--primary); font-weight: 500; font-size: 14px; }
.entry-actions { display: flex; gap: 8px; align-items: center; }

/* BUTTONS */
.btn-action { padding: 6px 14px; border: 1px solid #ddd; background: var(--white); border-radius: 3px; cursor: pointer; font-size: 13px; color: var(--text-light); text-decoration: none; display: inline-block; }
.btn-action:hover { background: #f5f5f5; border-color: #bbb; text-decoration: none; }
.btn-action.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-action.primary:hover { background: var(--primary-hover); }

/* VOTE */
.vote-btn { background: none; border: 1px solid #ddd; border-radius: 3px; padding: 2px 6px; cursor: pointer; font-size: 12px; color: var(--text-lighter); display: inline-flex; align-items: center; gap: 3px; }
.vote-btn:hover { border-color: var(--primary); color: var(--primary); }
.vote-btn.vote-up.active { background: #27ae60; color: #fff; border-color: #27ae60; }
.vote-btn.vote-down.active { background: #c0392b; color: #fff; border-color: #c0392b; }
.vote-count { font-size: 13px; color: var(--text-lighter); }

/* FAVORITE */
.fav-btn { background: none; border: 1px solid #ddd; border-radius: 3px; padding: 2px 6px; cursor: pointer; font-size: 14px; color: #ddd; }
.fav-btn:hover { color: #e74c3c; border-color: #e74c3c; }
.fav-btn.active { color: #e74c3c; border-color: #e74c3c; }

/* FORM */
.topic-actions { padding: 14px 28px; border-bottom: 1px solid var(--border); background: #fafafa; }
.entry-form { background: var(--white); border: 1px solid #ddd; border-radius: 3px; padding: 12px; }
.entry-form textarea { width: 100%; border: 1px solid #ddd; border-radius: 3px; padding: 10px 12px; font-size: 14px; line-height: 1.6; resize: vertical; min-height: 80px; font-family: inherit; outline: none; }
.entry-form textarea:focus { border-color: #999; }
.entry-form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-light); cursor: pointer; }

/* AUTH */
.auth-container { display: flex; justify-content: center; padding: 40px 24px; }
.auth-card { background: var(--white); border: 1px solid var(--border); border-radius: 4px; padding: 32px; width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 20px; text-align: center; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 3px; font-size: 14px; outline: none; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: #999; }
.form-group select { background: #fff; cursor: pointer; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.auth-links { text-align: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-light); }

/* PROFILE */
.profile-header { padding: 18px 28px; border-bottom: 1px solid var(--border); }
.profile-header h1 { font-size: 18px; font-weight: 600; }
.profile-username { color: var(--text-light); font-size: 14px; margin-top: 2px; }
.profile-stats { margin-top: 6px; font-size: 13px; color: var(--text-lighter); display: flex; gap: 10px; }
.profile-tabs { display: flex; border-bottom: 1px solid var(--border); }
.profile-tab { padding: 12px 24px; color: var(--text-light); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.profile-tab:hover { color: var(--text); text-decoration: none; }
.profile-tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 500; }

/* SEARCH */
.search-header { padding: 16px 28px; border-bottom: 1px solid var(--border); }
.search-header h1 { font-size: 18px; }
.search-meta { color: var(--text-lighter); font-size: 13px; margin-top: 2px; }
.topic-card { padding: 10px 28px; border-bottom: 1px solid #f0f0f0; }
.topic-card:hover { background: #f8f8f8; }
.topic-card h3 { font-size: 15px; }
.topic-card h3 a { color: var(--text); }
.topic-card h3 a:hover { color: var(--primary); text-decoration: none; }
.topic-card .card-meta { font-size: 12px; color: var(--text-lighter); margin-top: 2px; }

/* EMPTY / PAGINATION / ERROR */
.empty-state { padding: 40px 28px; text-align: center; color: var(--text-light); font-size: 14px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 18px 28px; border-top: 1px solid var(--border); }
.page-info { color: var(--text-light); font-size: 13px; }
.error-page { padding: 50px 28px; text-align: center; }
.error-page h1 { font-size: 56px; font-weight: 700; color: var(--text-lighter); }
.error-page h2 { font-size: 18px; margin: 8px 0; }
.error-page p { color: var(--text-light); margin-bottom: 16px; font-size: 14px; }

/* ALERTS */
.alert { padding: 10px 18px; margin: 12px 28px; border-radius: 3px; font-size: 13px; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-error { background: #fce4ec; color: #c62828; border: 1px solid #f8bbd0; }

/* NAV DROPDOWN */
.nav-dropdown { position: relative; }
.nav-dropdown-btn { background: none; border: none; padding: 12px 16px; color: var(--text-light); font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.nav-dropdown-btn:hover { color: var(--text); }
.nav-dropdown-content { display: none; position: absolute; top: 100%; right: 0; background: var(--white); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 180px; z-index: 200; padding: 6px 0; }
.nav-dropdown:hover .nav-dropdown-content { display: block; }
.nav-dropdown-content a { display: block; padding: 8px 16px; color: var(--text); font-size: 13px; }
.nav-dropdown-content a:hover { background: #f5f5f5; color: var(--primary); text-decoration: none; }

/* FOLLOW */
.follow-btn { cursor: pointer; }
.followed-cats { padding: 12px 20px; display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--border); }
.followed-cat-tag { padding: 4px 12px; background: #f0f0f0; border-radius: 3px; font-size: 13px; color: var(--primary); text-decoration: none; }
.followed-cat-tag:hover { background: var(--primary); color: #fff; text-decoration: none; }

/* ENTRY ADMIN PANEL */
.entry-admin-panel { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e8e8e8; }
.entry-admin-btn { background: none; border: 1px solid #ddd; border-radius: 2px; padding: 2px 8px; cursor: pointer; font-size: 11px; color: var(--text-light); text-decoration: none; }
.entry-admin-btn:hover { background: #f5f5f5; border-color: #bbb; }
.entry-admin-btn.danger { color: #c0392b; }
.entry-admin-btn.danger:hover { background: #fdf0ef; border-color: #c0392b; }
.entry-move-form { margin-left: auto; }

/* ADMIN */
.admin-body { background: var(--bg); }
.admin-header { background: var(--primary); }
.admin-header .header-inner { padding: 10px 24px; }
.admin-header .logo a { color: #fff; }
.admin-header .header-nav a { color: rgba(255,255,255,.7); }
.admin-header .header-nav a:hover { color: #fff; }
.admin-container { max-width: 1200px; margin: 0 auto; display: flex; min-height: calc(100vh - 50px); background: var(--white); border: 1px solid var(--border); }
.admin-sidebar { width: 220px; min-width: 220px; border-right: 1px solid var(--border); padding: 12px 0; }
.admin-nav { display: flex; flex-direction: column; }
.admin-nav a { padding: 10px 16px; color: var(--text-light); font-size: 14px; border-left: 2px solid transparent; }
.admin-nav a:hover { background: #f8f8f8; color: var(--text); text-decoration: none; }
.admin-nav a.active { color: var(--text); border-left-color: var(--accent); font-weight: 500; background: #f8f8f8; }
.admin-content { flex: 1; padding: 20px; }
.admin-page h1 { font-size: 18px; font-weight: 600; margin-bottom: 18px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #f8f9fa; border: 1px solid var(--border); border-radius: 4px; padding: 18px; text-align: center; }
.stat-card h3 { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card p { color: var(--text-light); font-size: 13px; margin-top: 3px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-light); border-bottom: 1px solid var(--border); text-transform: uppercase; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.admin-table tr:hover { background: #f8f8f8; }
.admin-table a { color: var(--primary); }

/* FOOTER */
footer { background: var(--white); border-top: 1px solid var(--border); padding: 16px 24px; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-lighter); }
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: var(--text-lighter); }
.footer-links a:hover { color: var(--text); }

/* RESPONSIVE */
@media (max-width: 900px) {
    .mobile-menu-btn { display: block; }
    .header-nav { display: none; }
    .main-nav { display: none; }
    .nav-dropdown { display: none; }
    .container { flex-direction: column; }
    .sidebar { display: none; }
    .topic-entry-block, .entry { padding: 14px 16px; }
    .topic-header { padding: 14px 16px; }
    .topic-entry-title { font-size: 18px; }
    .topic-entry-content { font-size: 15px; }
    .entry-content { font-size: 15px; }
    .admin-container { flex-direction: column; }
    .admin-sidebar { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
    .admin-nav { flex-direction: row; overflow-x: auto; }
    .admin-nav a { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
}
@media (max-width: 600px) {
    .header-inner { padding: 10px 12px; gap: 12px; }
    .logo a { font-size: 20px; }
    .search-box input { font-size: 13px; padding: 6px 10px; }
    .btn-search { padding: 6px 14px; font-size: 13px; }
    .topic-header h1 { font-size: 18px; }
    .topic-entry-title { font-size: 16px; }
    .topic-entry-content { font-size: 14px; line-height: 1.7; }
    .entry-content { font-size: 14px; line-height: 1.7; }
    .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}
@media (min-width: 901px) {
    .mobile-menu { display: none; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.3s ease-out; }
/* ENTRY FORM BOTTOM */
.entry-form-bottom { padding: 16px 28px; border-top: 1px solid var(--border); background: #fafafa; }
.entry-form-bottom textarea { width: 100%; border: 1px solid #ddd; border-radius: 3px; padding: 10px 12px; font-size: 14px; line-height: 1.6; resize: vertical; min-height: 80px; font-family: inherit; outline: none; }
.entry-form-bottom textarea:focus { border-color: #999; }
.entry-form-bottom-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.link-insert-btn { background: none; border: 1px solid #ddd; border-radius: 3px; padding: 4px 12px; cursor: pointer; font-size: 12px; color: var(--text-light); }
.link-insert-btn:hover { background: #f5f5f5; border-color: #bbb; }

/* MODAL */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 2000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--white); border-radius: 6px; width: 90%; max-width: 400px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-light); padding: 2px 6px; }
.modal-close-btn:hover { color: var(--text); }
.modal-body { padding: 16px; }

/* TOPIC ADMIN EDIT */
.topic-admin-bar { padding: 8px 28px; background: #f8f9fa; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; font-size: 12px; }
.topic-admin-bar a, .topic-admin-bar button { font-size: 12px; }