:root {
    --bg-dark: #050507;
    --card-bg: rgba(17, 17, 21, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary: #22d3ee;
    --accent: #8b5cf6;
    --text-main: #e2e8f0;
    /* Slate 200 - vibrant grey for dark mode content */
    --text-title: #ffffff;
    /* Pure white for dark mode titles */
    --text-muted: #94a3b8;
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
    --glass-grad: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    --neon-glow: 0 0 20px rgba(34, 211, 238, 0.15);
}

body.light-mode {
    --bg-dark: #ffffff;
    --card-bg: #f8fafc;
    --border-color: #e2e8f0;
    --text-main: #334155;
    /* Slate 700 - solid dark for light mode body */
    --text-title: #0f172a;
    /* Slate 900 - very dark for light mode titles */
    --text-muted: #64748b;
    --primary: #0891b2;
    --accent: #7c3aed;
    --glass-grad: linear-gradient(135deg, rgba(0, 0, 0, 0.02) 0%, rgba(0, 0, 0, 0.01) 100%);
    --neon-glow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 40%),
        linear-gradient(rgba(34, 211, 238, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 211, 238, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 50px 50px, 50px 50px;
}

body.light-mode {
    background-image:
        radial-gradient(circle at 20% 20%, rgba(0, 0, 0, 0.01) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(0, 0, 0, 0.01) 0%, transparent 40%);
}

/* Reading Progress Bar */
#progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 1000;
}

#progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--accent));
    width: 0%;
    box-shadow: 0 0 10px var(--primary);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    margin-bottom: 3rem;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.hero h1 {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, #22d3ee, #8b5cf6, #22d3ee);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -2px;
    animation: shine 5s linear infinite;
}

@keyframes shine {
    to {
        background-position: 200% center;
    }
}

/* Post Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 2rem;
    backdrop-filter: blur(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Card Mouse Glow Effect */
.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at var(--mouse-x) var(--mouse-y), rgba(34, 211, 238, 0.15) 0%, transparent 80%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--glass-grad);
    z-index: -1;
}

.card:hover .card-glow {
    opacity: 1;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(34, 211, 238, 0.4);
    box-shadow: var(--neon-glow);
}

.card h2 {
    margin-bottom: 1rem;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
}

.card p {
    color: var(--text-muted);
    font-size: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Post Detail Styles */
.post-title {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    font-family: var(--font-heading);
    background: linear-gradient(to right, var(--text-title), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: none;
    /* Avoid flickering gradients */
}

.post-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-main) !important;
}

.post-content * {
    color: inherit !important;
}

.post-content h1,
.post-content h2,
.post-content h3 {
    margin: 2.5rem 0 1.25rem;
    color: var(--text-title) !important;
    font-family: var(--font-heading);
}

.post-content img {
    max-width: 100%;
    border-radius: 1rem;
    margin: 2rem 0;
}

/* Tags Style */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tag {
    font-size: 0.75rem;
    background: rgba(34, 211, 238, 0.1);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-weight: 600;
    border: 1px solid rgba(34, 211, 238, 0.2);
}

body.light-mode .tag {
    background: #ecfeff;
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

/* Admin Auth */
.login-container {
    max-width: 400px;
    margin: 10vh auto;
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

input,
textarea,
select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1rem;
    border-radius: 0.5rem;
    color: white;
    margin-bottom: 1rem;
    font-family: inherit;
}

button {
    background: linear-gradient(to right, var(--primary), var(--accent));
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

button:hover {
    opacity: 0.9;
}

/* Admin Styles */
.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 3rem;
    min-height: 80vh;
}

.sidebar {
    border-right: 1px solid var(--border-color);
    padding-right: 2rem;
}

.logo-admin {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: 3rem;
    color: var(--text-main);
}

.nav-item {
    padding: 0.8rem 1.25rem;
    cursor: pointer;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(34, 211, 238, 0.1);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

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

.btn-danger:hover {
    background: #ef4444;
    color: white;
}

/* Quill & Editor Overrides */
.editor-container {
    background: #ffffff;
    border-radius: 0.75rem;
    overflow: hidden;
    margin-top: 1.5rem;
}

.ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid #f1f1f1;
    background: #fcfcfc;
}

.ql-container.ql-snow {
    border: none;
    font-family: var(--font-body);
    font-size: 1rem;
}

#html-editor {
    background: #18181b;
    color: #e4e4e7;
    border: 1px solid var(--border-color);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Response Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
}

/* Spinner Animation */
.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid rgba(34, 211, 238, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: #27272a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3f3f46;
}

button.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

/* Admin Dashboard */
.admin-layout {
    display: flex;
    gap: 2rem;
}

.sidebar {
    width: 250px;
}

.logo-admin {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 2rem;
    color: var(--text-main);
}

.nav-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.content {
    flex: 1;
}

.editor-container {
    background: white;
    color: black;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
    min-height: 300px;
}

/* Quill Overrides for Dark Mode wrapper */
.ql-toolbar {
    background: #f3f4f6;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

.ql-container {
    background: white;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    font-size: 1rem;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-muted);
    font-weight: 500;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    width: auto;
    display: inline-block;
    margin-right: 0.5rem;
}

.btn-danger {
    background: #ef4444;
    color: white;
}