* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --bg: #13141f;
    --bg-secondary: #1a1b2e;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-bg-hover: rgba(255, 255, 255, 0.1);
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --glass-bg: rgba(20, 21, 35, 0.85);
}

body {
    font-family: 'Outfit', 'Noto Serif SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
}

a {
    color: inherit;
    text-decoration: none;
}

/* Header with Glassmorphism */
.site-header {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    position: relative;
}

.nav a:hover {
    color: var(--text);
    background: var(--card-bg-hover);
}

.nav a.active {
    color: var(--text);
    background: var(--card-bg-hover);
}

.nav a.active::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

/* Search Form */
.search-form {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.search-form input {
    padding: 6px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    width: 140px;
    transition: all 0.3s ease;
}

.search-form input:focus {
    outline: none;
    border-color: var(--primary);
    width: 180px;
}

.search-form input::placeholder {
    color: var(--text-muted);
}

.search-form button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    font-size: 1rem;
    transition: color 0.2s;
}

.search-form button:hover {
    color: var(--primary);
}

/* Avatar Circle */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    text-transform: uppercase;
    box-shadow: 0 0 20px var(--primary-glow);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: default;
}

.username {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
}

.user-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.logout-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logout-form button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
}

.logout-form button:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--card-bg-hover);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 40px 0 60px;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -2px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #fff 0%, #c7d2fe 50%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

/* Section Title */
.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 2px;
}

.post-count {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Posts Grid */
.posts-section {
    padding: 40px 0 80px;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.post-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.post-card:hover {
    background: var(--card-bg-hover);
    border-color: var(--border-hover);
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.post-link {
    display: block;
    padding: 28px;
}

.post-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
    line-height: 1.4;
    transition: color 0.3s;
}

.post-card:hover .post-title {
    color: #a5b4fc;
}

.post-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.post-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.post-meta .author {
    color: var(--primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 48px;
}

.pagination .btn {
    padding: 10px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    transition: all 0.3s ease;
}

.pagination .btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
}

.page-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.empty-state p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    gap: 8px;
}

.btn:hover {
    background: var(--card-bg-hover);
    border-color: var(--border-hover);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
}

.post-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.delete-form {
    display: inline;
}

/* Footer */
.site-footer {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    margin-top: auto;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Auth Pages */
.auth-page {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px;
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(20px);
}

.auth-card h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-card .subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.auth-card .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 8px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary);
    font-weight: 500;
    transition: color 0.3s;
}

.auth-footer a:hover {
    color: #a5b4fc;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    border: 1px solid;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Post Detail */
.post-detail {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 40px 0;
    backdrop-filter: blur(20px);
}

.post-header {
    padding: 48px;
    border-bottom: 1px solid var(--border);
}

.post-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.3;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.post-meta {
    display: flex;
    gap: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.post-meta span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-meta .author {
    color: var(--primary);
}

.post-content {
    padding: 48px;
    font-size: 1.1rem;
    line-height: 1.9;
}

.post-content h1, .post-content h2, .post-content h3 {
    margin: 40px 0 20px;
    line-height: 1.4;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.post-content p {
    margin-bottom: 24px;
}

.post-content ul, .post-content ol {
    margin: 24px 0;
    padding-left: 28px;
}

.post-content li {
    margin-bottom: 10px;
}

.post-content code {
    background: var(--bg-secondary);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Monaco', monospace;
    font-size: 0.9em;
    color: #a5b4fc;
    border: 1px solid var(--border);
}

.post-content pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 24px 0;
}

.post-content pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
    border: none;
}

.post-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 24px;
    margin: 32px 0;
    color: var(--text-secondary);
    font-style: italic;
    background: var(--card-bg);
    padding: 20px 24px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.post-content a {
    color: var(--primary);
}

.post-content a:hover {
    text-decoration: underline;
}

.post-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 24px 0;
    border: 1px solid var(--border);
}

/* Comments */
.comments-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    margin-bottom: 40px;
    backdrop-filter: blur(20px);
}

.comments-section h2 {
    font-size: 1.2rem;
    margin-bottom: 24px;
    color: var(--text);
}

.comment-form {
    margin-bottom: 32px;
}

.comment-form textarea {
    width: 100%;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    min-height: 120px;
    resize: vertical;
    margin-bottom: 12px;
    color: var(--text);
    transition: all 0.3s ease;
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment {
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.comment-author {
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.comment-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.comment-actions {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.comment-delete-form,
.comment-edit-form {
    margin-left: 12px;
}

.comment-delete-form .btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.comment-delete-form .btn-link:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.comment-edit-form {
    margin-top: 12px;
}

.comment-edit-form .edit-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.comment-edit-form .edit-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.comment-edit-form .form-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.comment-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

.login-prompt {
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    text-align: center;
}

.login-prompt a {
    color: var(--primary);
    font-weight: 500;
}

/* Editor */
.editor-page {
    max-width: 900px;
    margin: 40px auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    backdrop-filter: blur(20px);
}

.editor-page h1 {
    font-size: 1.5rem;
    margin-bottom: 32px;
    color: var(--text);
}

.editor-form .form-group {
    margin-bottom: 24px;
}

.editor-form textarea {
    min-height: 450px;
    font-family: 'JetBrains Mono', 'Monaco', monospace;
    line-height: 1.7;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* 404 */
.error-page {
    text-align: center;
    padding: 120px 24px;
}

.error-page h1 {
    font-size: 8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.error-page p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Admin Pages */
.admin-page {
    max-width: 1200px;
    margin: 40px auto;
}

.admin-page h1 {
    font-size: 1.75rem;
    margin-bottom: 24px;
    color: var(--text);
}

.admin-page .btn {
    margin-bottom: 20px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    backdrop-filter: blur(20px);
}

.stat-card h3 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.admin-nav {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.admin-nav-btn {
    padding: 16px 32px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 600;
    transition: all 0.3s ease;
}

.admin-nav-btn:hover {
    background: var(--card-bg-hover);
    border-color: var(--border-hover);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-table th,
.admin-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: var(--card-bg-hover);
}

.admin-table select {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.admin-table a {
    color: var(--primary);
}

.admin-table a:hover {
    text-decoration: underline;
}

.comment-content {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.2rem;
    }

    .hero {
        padding: 60px 0 40px;
    }

    .posts-grid {
        grid-template-columns: 1fr;
    }

    .post-header {
        padding: 24px;
    }

    .post-content {
        padding: 24px;
    }

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

    .header-inner {
        padding: 12px 16px;
    }

    .nav {
        gap: 4px;
    }

    .nav a {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .post-meta {
        flex-wrap: wrap;
        gap: 12px;
    }
}