:root {
    /* Light Mode Variables */
    --bg-color: #ffffff;
    --bg-rgb: 255, 255, 255;
    --bg-secondary: #f9fafb;
    --text-color: #111827;
    --text-secondary: #4b5563;
    --primary-color: #000000;
    --primary-hover: #333333;
    --border-color: #e5e7eb;
    --card-bg: rgba(255, 255, 255, 0.8);
    --header-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-serif: 'Merriweather', Georgia, serif;
}

/* Dark Mode can be on body OR html (for immediate load) */
body.dark-mode, html.dark-mode body {
    /* Dark Mode Variables - Pure Black */
    --bg-color: #000000;
    --bg-rgb: 0, 0, 0;
    --bg-secondary: #000000;
    --text-color: #ededed;
    --text-secondary: #a1a1a1;
    --primary-color: #ffffff;
    --primary-hover: #cccccc;
    --border-color: #333333;
    /* Semi-transparent black */
    --card-bg: rgba(0, 0, 0, 0.7);
    --header-bg: rgba(0, 0, 0, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.12);
    --shadow-sm: none;
    --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.8);
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
header {
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 0;
    margin-bottom: 3rem;
    transition: border-color 0.3s, background-color 0.3s;
}

header .header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(125, 125, 125, 0.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh; /* Use dynamic viewport height for mobile */
    background: rgba(var(--bg-rgb), 0.95);
    background: var(--bg-color);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-right: var(--glass-border);
    padding: 0;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .side-menu {
        width: 100%; /* Full width on desktop too */
        max-width: none;
        box-shadow: none;
    }
}

/* Glass effect override if supported */
@supports (backdrop-filter: blur(20px)) {
    .side-menu {
        background: rgba(var(--bg-rgb), 0.9);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
}

/* Ensure content is scrollable but scrollbar is hidden */
.side-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    scrollbar-width: none; /* Firefox */
}

.side-menu-content::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Webkit */
}

.side-menu.active {
    transform: translateX(0);
}

.sun-icon { display: none; }
.moon-icon { display: block; }
body.dark-mode .sun-icon { display: block; }
body.dark-mode .moon-icon { display: none; }

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2.5rem; /* Increased padding */
}

.menu-title {
    font-size: 2rem; /* Larger title */
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-logo {
    height: 1.2em;
    width: auto;
    object-fit: contain;
}

.menu-section {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 500px; /* Constrain content width for readability */
    margin-left: auto;
    margin-right: auto;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Increased gap */
}

.side-nav a, .nav-item-toggle {
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.5rem; /* Much larger font size */
    font-weight: 700;
    transition: all 0.2s ease;
    padding: 1.25rem 1.5rem; /* Larger touch targets */
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    background: transparent;
    border: none;
    width: 100%;
    cursor: pointer;
    font-family: var(--font-sans);
    text-align: left;
}

.nav-item-toggle .flex-center {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.side-nav a:hover, .nav-item-toggle:hover {
    background-color: rgba(125, 125, 125, 0.08);
    transform: translateX(8px); /* More pronounced movement */
}

.side-nav a.active {
    background-color: var(--text-color);
    color: var(--bg-color);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.side-nav a.active:hover {
    transform: none;
}

.side-nav a svg, .nav-item-toggle svg:not(.chevron) {
    opacity: 0.8;
}

.side-nav a.active svg {
    opacity: 1;
}

/* Sub-menu */
.nav-sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 1.5rem;
    padding-left: 1.5rem;
    border-left: 3px solid var(--border-color); /* Thicker border */
    opacity: 0;
}

.nav-sub-menu.open {
    max-height: 2000px;
    opacity: 1;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.nav-sub-menu a {
    font-size: 1.25rem; /* Larger sub-menu font */
    font-weight: 500;
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
}

.nav-sub-menu a:hover {
    color: var(--text-color);
    background: transparent;
    transform: translateX(4px);
}

.nav-sub-menu a.active {
    color: var(--primary-color);
    background: transparent;
    box-shadow: none;
    font-weight: 700;
}

/* Chevron Rotation */
.chevron {
    transition: transform 0.3s ease;
    opacity: 0.5;
}

.nav-item-toggle.active .chevron {
    transform: rotate(180deg);
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 2rem 1.5rem; /* More spacing */
    opacity: 0.5;
}

.empty-state {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 1rem;
    display: block;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.95); /* Darker overlay for focus */
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align to top */
    padding-top: 10vh; /* Space from top */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(10px);
    overflow-y: auto;
}

body.light-mode .search-overlay {
    background: rgba(255, 255, 255, 0.98);
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-container {
    width: 100%;
    max-width: 800px;
    padding: 0 2rem;
    margin: 0 auto;
}

.search-form-overlay {
    width: 100%;
    max-width: 100%; /* Full width of container */
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
}

.search-form-overlay input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--text-secondary);
    font-size: 2.5rem; /* Larger font */
    color: var(--text-color);
    padding: 1rem 0;
    border-radius: 0;
    outline: none;
    font-family: var(--font-serif); /* Serif for impact */
    font-weight: 300;
}

.search-form-overlay input:focus {
    border-color: var(--primary-color);
    box-shadow: none;
}

.search-form-overlay #search-close {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    width: 48px;
    height: 48px;
}

.search-form-overlay #search-close svg {
    width: 32px;
    height: 32px;
}

/* Search Results */
.search-results {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 4rem;
}

.search-result-item {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: block;
    text-decoration: none;
    animation: fadeIn 0.3s ease forwards;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: block;
    transition: color 0.2s;
}

body.light-mode .search-result-title {
    color: #000000; /* Force black in light mode */
}

.search-result-item:hover .search-result-title {
    color: var(--primary-color);
}

.search-result-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.search-no-results {
    color: var(--text-secondary);
    font-size: 1.2rem;
    text-align: center;
    margin-top: 2rem;
}

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

.search-form-overlay #search-close:hover {
    opacity: 1;
    background: none;
}

/* Theme Toggle - Updated for new header */
#theme-toggle {
    width: 40px;
    height: 40px;
}

/* Posts List */
.posts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
}

.posts-list .ad-container {
    grid-column: 1 / -1;
}

.post-card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--text-secondary);
}

.post-title {
    margin-top: 0;
    font-family: var(--font-sans);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.post-title a {
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s;
}

.post-title a:hover {
    color: var(--text-secondary);
}

.post-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-excerpt {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
    flex-grow: 1;
}

.read-more {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
    margin-top: auto;
}

.read-more:hover {
    border-bottom-color: var(--text-color);
}

/* Single Post & Pages */
.single-post, 
.page-content {
    max-width: 800px;
    margin: 0 auto;
}

.single-post h1 {
    font-family: var(--font-sans);
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    letter-spacing: -0.04em;
}

.post-content {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--text-color);
    line-height: 1.9;
    margin-top: 3rem;
}

.post-content p {
    margin-bottom: 2rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 3rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

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

/* Forms & Buttons */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem;
    border: var(--glass-border);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 1rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: border-color 0.2s;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

button {
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    font-family: var(--font-sans);
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Table */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: var(--glass-border);
    backdrop-filter: blur(10px);
}

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

th {
    background-color: rgba(125, 125, 125, 0.1);
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.actions a,
.actions button {
    margin-right: 1rem;
    text-decoration: none;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.actions a:hover,
.actions button:hover {
    background-color: rgba(125, 125, 125, 0.1);
}

.actions a.edit { color: var(--text-color); }
.actions a.delete { color: #ef4444; }
.actions button.delete { color: #ef4444; }

/* Utilities */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    gap: 0.5rem; /* Better spacing for icons */
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
}

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

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

footer {
    border-top: var(--glass-border);
    padding: 3rem 0;
    margin-top: 5rem;
    background-color: transparent;
    text-align: center;
    color: var(--text-secondary);
}

body.dark-mode .sun-icon { display: block; }
body.dark-mode .moon-icon { display: none; }
body:not(.dark-mode) .sun-icon { display: none; }
body:not(.dark-mode) .moon-icon { display: block; }
