/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #FFFFFF;
    --bg-surface: #F7F8FA;
    --bg-hover: #EEF0F4;
    --text: #1A1A2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --accent: #1A1A2E;
    --accent-hover: #2D2D44;
    --border: #E5E7EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-surface);
    line-height: 1.6;
    font-size: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ========== Container ========== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* ========== Header ========== */
.site-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.site-logo:hover { color: var(--accent); }
.main-nav { display: flex; align-items: center; gap: 1rem; }
.main-nav a { color: var(--text-secondary); font-size: 0.9rem; }
.main-nav a:hover { color: var(--accent); }

/* User Dropdown */
.user-menu { position: relative; }
.user-menu-trigger {
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text);
}
.user-menu-trigger:hover { background: var(--bg-surface); }
.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    min-width: 140px;
    z-index: 200;
}
.user-menu:hover .user-dropdown { display: block; }
.user-dropdown a, .dropdown-link {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--text);
    font-size: 0.9rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: var(--font);
}
.user-dropdown a:hover, .dropdown-link:hover { background: var(--bg-surface); color: var(--accent); }

/* ========== Main ========== */
.site-main { flex: 1; padding: 2rem 0; }

/* ========== Footer ========== */
.site-footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* ========== Buttons ========== */
.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-family: var(--font);
    line-height: 1.5;
    background: var(--bg-surface);
    color: var(--text);
}
.btn:hover { background: var(--bg-hover); color: var(--text); }
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg-surface); color: var(--text-secondary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; }
.inline-form { display: inline; }

/* ========== Forms ========== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.9rem; color: var(--text-secondary); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
textarea, select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: border-color 0.2s;
    background: var(--bg);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.input-disabled { background: var(--bg-surface); color: var(--text-muted); }

/* ========== Flash Messages ========== */
.flash {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    animation: flashIn 0.3s ease;
}
.flash-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ========== Badges ========== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-surface);
    color: var(--text-secondary);
}
.badge-success { background: #ECFDF5; color: #065F46; }
.badge-warning { background: #FFFBEB; color: #92400E; }
.badge-danger { background: #FEF2F2; color: #991B1B; }
.badge-primary { background: #EFF6FF; color: #1E40AF; }

/* ========== Hero ========== */
.hero-section { text-align: center; padding: 2rem 0 1.5rem; }
.hero-section h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.3rem; }
.hero-tagline { color: var(--text-muted); font-size: 1rem; }

/* ========== Article Grid ========== */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.article-card {
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s, transform 0.2s;
}
.article-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card-cover { display: block; aspect-ratio: 16/9; overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.article-card:hover .card-cover img { transform: scale(1.03); }
.card-body { padding: 1rem 1.2rem; }
.card-title { font-size: 1.1rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.4rem; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent); }
.card-summary { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; margin-bottom: 0.6rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 0.8rem; flex-wrap: wrap; }

/* ========== Article Full ========== */
.article-full { max-width: 780px; margin: 0 auto; }
.article-header { margin-bottom: 1.5rem; }
.article-title { font-size: 2rem; font-weight: 700; line-height: 1.3; margin-bottom: 0.8rem; }
.article-meta { display: flex; gap: 1rem; flex-wrap: wrap; color: var(--text-muted); font-size: 0.9rem; align-items: center; }
.article-cover { margin-bottom: 1.5rem; border-radius: var(--radius); overflow: hidden; }
.article-cover img { width: 100%; }
.article-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text);
}
.article-content h1, .article-content h2, .article-content h3 { margin: 1.5rem 0 0.8rem; font-weight: 600; }
.article-content h2 { font-size: 1.5rem; }
.article-content h3 { font-size: 1.25rem; }
.article-content p { margin-bottom: 1rem; }
.article-content img { border-radius: var(--radius); margin: 1rem 0; }
.article-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1rem 0; color: var(--text-secondary); }
.article-content pre { background: #1E293B; color: #E2E8F0; padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin: 1rem 0; font-size: 0.9rem; }
.article-content code { background: var(--bg-surface); padding: 0.15rem 0.4rem; border-radius: 3px; font-size: 0.9em; }
.article-content pre code { background: none; padding: 0; }
.article-content ul, .article-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.article-content li { margin-bottom: 0.3rem; }
.article-actions { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; }

/* ========== Comments ========== */
.comments-section { max-width: 780px; margin: 3rem auto 0; padding-top: 2rem; border-top: 1px solid var(--border); }
.comments-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 1.5rem; }
.comments-list { margin-bottom: 2rem; }
.comment-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.comment-item:last-of-type { border-bottom: none; }
.comment-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.comment-author { font-weight: 500; font-size: 0.9rem; }
.comment-date { color: var(--text-muted); font-size: 0.8rem; }
.comment-delete-btn { background: none; border: none; color: var(--text-muted); font-size: 0.75rem; cursor: pointer; padding: 0; }
.comment-delete-btn:hover { color: var(--danger); }
.comment-content { font-size: 0.95rem; line-height: 1.6; color: var(--text-secondary); }
.comment-form { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.comment-form h3 { font-size: 1rem; margin-bottom: 0.8rem; font-weight: 600; }
.comment-guest-note, .comment-user-note { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.8rem; }

/* ========== Editor Page ========== */
.editor-page { max-width: 900px; margin: 0 auto; }
.input-title { border: none; font-size: 1.8rem; font-weight: 700; padding: 0.5rem 0; width: 100%; }
.input-title:focus { outline: none; box-shadow: none; }
.input-summary { border: none; font-size: 1rem; color: var(--text-secondary); padding: 0.3rem 0; width: 100%; border-bottom: 1px solid var(--border); }
.input-summary:focus { outline: none; box-shadow: none; border-color: var(--accent); }
#editor { min-height: 400px; background: var(--bg); border-radius: var(--radius); }
.form-actions { display: flex; gap: 0.8rem; margin-top: 1.5rem; justify-content: flex-end; }

/* Cover upload */
.cover-upload { display: flex; align-items: center; gap: 1rem; }
.cover-preview { width: 200px; height: 120px; border: 2px dashed var(--border); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.85rem; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ========== Auth Pages ========== */
.auth-page { display: flex; justify-content: center; padding-top: 3rem; }
.auth-card { background: var(--bg); padding: 2rem; border-radius: var(--radius); border: 1px solid var(--border); width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 1.5rem; text-align: center; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.9rem; color: var(--text-muted); }

/* ========== Profile ========== */
.profile-page { max-width: 700px; margin: 0 auto; }
.profile-page h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.profile-page h2 { font-size: 1.2rem; margin: 2rem 0 1rem; }
.profile-page h3 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--text-secondary); }
.profile-card { background: var(--bg); padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--border); }
.article-list-item { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.5rem; }
.list-item-info { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.list-item-title { font-weight: 500; color: var(--text); }

/* ========== Error Pages ========== */
.error-page { text-align: center; padding: 4rem 0; }
.error-page h1 { font-size: 5rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.5rem; }
.error-page p { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 1.1rem; }

/* ========== Empty State ========== */
.empty-state { text-align: center; padding: 4rem 0; color: var(--text-secondary); }
.empty-state h2 { font-size: 1.3rem; margin-bottom: 0.5rem; color: var(--text); }
.empty-state .btn { margin-top: 1rem; }

/* ========== Pagination ========== */
.pagination { display: flex; justify-content: center; gap: 0.3rem; margin-top: 2rem; }
.page-link { display: inline-block; padding: 0.4rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; color: var(--text-secondary); background: var(--bg); }
.page-link:hover { background: var(--bg-surface); color: var(--accent); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ========== Utilities ========== */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .article-grid { grid-template-columns: 1fr; }
    .article-title { font-size: 1.5rem; }
    .input-title { font-size: 1.3rem; }
    .header-inner { padding: 0 0.5rem; }
    .main-nav { gap: 0.5rem; }
    .cover-upload { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .article-grid { grid-template-columns: repeat(2, 1fr); }
}
