:root {
    --bg: #f3f5f9;
    --panel: #ffffff;
    --text: #172033;
    --muted: #697386;
    --brand: #4f46e5;
    --brand-dark: #3730a3;
    --danger: #dc2626;
    --border: #e3e8f0;
    --shadow: 0 18px 40px rgba(23, 32, 51, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(79, 70, 229, .16), transparent 32rem),
        var(--bg);
    color: var(--text);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.site-header {
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav {
    max-width: 1060px;
    margin: 0 auto;
    padding: 16px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 800;
    font-size: 21px;
}

.logo-mark {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--brand), #06b6d4);
    display: inline-grid;
    place-items: center;
    color: white;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(79, 70, 229, .28);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-links a,
.nav-pill {
    color: var(--text);
    padding: 9px 12px;
    border-radius: 999px;
    font-size: 14px;
}

.nav-links a:hover {
    background: #eef2ff;
    text-decoration: none;
}

.nav-pill {
    background: #eef2ff;
    color: var(--brand-dark);
}

.container {
    max-width: 1060px;
    margin: 0 auto;
    padding: 34px 22px 70px;
}

.hero {
    background: linear-gradient(135deg, #111827, #3730a3);
    color: white;
    border-radius: 28px;
    padding: 42px;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.hero:after {
    content: "";
    position: absolute;
    width: 280px;
    height: 280px;
    right: -80px;
    top: -80px;
    background: rgba(255,255,255,.12);
    border-radius: 50%;
}

.hero h1 {
    margin: 0 0 10px;
    font-size: clamp(34px, 6vw, 58px);
    letter-spacing: -0.05em;
    line-height: .95;
}

.hero p {
    color: #dbeafe;
    margin: 0;
    max-width: 620px;
    font-size: 18px;
    line-height: 1.6;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.post-card {
    transition: transform .18s ease, box-shadow .18s ease;
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 48px rgba(23, 32, 51, .12);
}

.post-card h2 {
    margin: 0 0 10px;
    font-size: 25px;
    letter-spacing: -0.03em;
}

.meta {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 14px;
}

.post-body {
    font-size: 18px;
    line-height: 1.75;
}

.button,
button {
    border: 0;
    background: var(--brand);
    color: white;
    padding: 11px 15px;
    border-radius: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
    box-shadow: 0 10px 22px rgba(79, 70, 229, .22);
}

.button:hover,
button:hover {
    background: var(--brand-dark);
    text-decoration: none;
}

.secondary {
    background: #eef2ff;
    color: var(--brand-dark);
    box-shadow: none;
}

.danger {
    background: var(--danger);
    box-shadow: none;
}

form.card {
    max-width: 720px;
}

label {
    display: block;
    margin: 12px 0 7px;
    font-weight: 750;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    background: #fbfcff;
    border-radius: 14px;
    padding: 13px 14px;
    font: inherit;
    color: var(--text);
}

textarea {
    min-height: 135px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    outline: 3px solid rgba(79,70,229,.16);
    border-color: var(--brand);
}

.page-title {
    font-size: 42px;
    letter-spacing: -0.05em;
    margin: 0 0 22px;
}

.comment {
    background: white;
    border: 1px solid var(--border);
    border-left: 5px solid var(--brand);
    border-radius: 18px;
    padding: 16px 18px;
    margin: 14px 0;
    box-shadow: 0 10px 22px rgba(23,32,51,.05);
}

.comment p {
    margin-bottom: 0;
    line-height: 1.55;
}

.table-wrap {
    overflow-x: auto;
    background: white;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.empty {
    background: white;
    border: 1px dashed var(--border);
    border-radius: 22px;
    padding: 34px;
    text-align: center;
    color: var(--muted);
}

.error {
    background: #fee2e2;
    color: #991b1b;
    border-radius: 14px;
    padding: 12px 14px;
    font-weight: 700;
}

.inline {
    display: inline;
}

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

@media (max-width: 760px) {
    .nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero {
        padding: 30px;
    }

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

    .page-title {
        font-size: 34px;
    }
}


.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #eef2ff;
    color: #3730a3;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.editor-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 16px;
}

#editor {
    min-height: 260px;
    background: white;
}

.ql-toolbar.ql-snow,
.ql-container.ql-snow {
    border: 0 !important;
}

.ql-toolbar.ql-snow {
    border-bottom: 1px solid var(--border) !important;
}

.small-form {
    display: flex;
    gap: 10px;
    align-items: end;
    margin-bottom: 22px;
}

.small-form input {
    margin-bottom: 0;
}

.small-form button {
    white-space: nowrap;
}


.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    margin: 12px 0 18px;
}

.check-row input {
    width: auto;
    margin: 0;
}


.theme-toggle {
    background: #eef2ff;
    color: #3730a3;
    box-shadow: none;
    padding: 8px 11px;
}

.seo-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    margin: 14px 0 18px;
}

.seo-box summary {
    cursor: pointer;
    font-weight: 800;
    color: var(--brand-dark);
}

/* Dark mode */
.dark-mode {
    --bg: #0f172a;
    --panel: #111827;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --brand: #818cf8;
    --brand-dark: #c7d2fe;
    --border: #243044;
    --shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.dark-mode body {
    background:
        radial-gradient(circle at top left, rgba(129, 140, 248, .16), transparent 32rem),
        var(--bg);
}

.dark-mode .site-header {
    background: rgba(17, 24, 39, .88);
}

.dark-mode .logo,
.dark-mode .nav-links a {
    color: var(--text);
}

.dark-mode .nav-links a:hover,
.dark-mode .nav-pill,
.dark-mode .theme-toggle,
.dark-mode .chip,
.dark-mode .secondary {
    background: #1e293b;
    color: #c7d2fe;
}

.dark-mode .card,
.dark-mode .comment,
.dark-mode .table-wrap,
.dark-mode input,
.dark-mode textarea,
.dark-mode select,
.dark-mode .editor-box,
.dark-mode #editor,
.dark-mode .ql-container {
    background: #111827;
    color: var(--text);
}

.dark-mode input,
.dark-mode textarea,
.dark-mode select {
    border-color: var(--border);
}

.dark-mode .seo-box {
    background: #0f172a;
}

.dark-mode .ql-toolbar {
    background: #f8fafc;
}


/* Stronger dark mode fixes */
html.dark-mode body {
    background:
        radial-gradient(circle at top left, rgba(129, 140, 248, .18), transparent 32rem),
        #0f172a !important;
    color: #e5e7eb !important;
}

html.dark-mode .site-header {
    background: rgba(17, 24, 39, .92) !important;
    border-bottom-color: #243044 !important;
}

html.dark-mode .card,
html.dark-mode .comment,
html.dark-mode .table-wrap,
html.dark-mode .empty {
    background: #111827 !important;
    color: #e5e7eb !important;
    border-color: #243044 !important;
}

html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select,
html.dark-mode .editor-box,
html.dark-mode #editor {
    background: #0f172a !important;
    color: #e5e7eb !important;
    border-color: #243044 !important;
}

html.dark-mode .logo,
html.dark-mode .nav-links a,
html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode p,
html.dark-mode td,
html.dark-mode th,
html.dark-mode label {
    color: #e5e7eb;
}

html.dark-mode .meta {
    color: #94a3b8;
}

html.dark-mode .nav-pill,
html.dark-mode .theme-toggle,
html.dark-mode .chip,
html.dark-mode .secondary {
    background: #1e293b !important;
    color: #c7d2fe !important;
}

html.dark-mode .theme-toggle {
    border: 1px solid #334155;
}


.category-admin-chip {
    padding-right: 6px;
}

.chip-delete {
    background: transparent;
    color: inherit;
    box-shadow: none;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 999px;
    font-size: 18px;
    line-height: 1;
}

.chip-delete:hover {
    background: rgba(220, 38, 38, .12);
    color: #dc2626;
}


.post-thumb {
    width: 100%;
    height: 210px;
    object-fit: cover;
    border-radius: 18px;
    margin-bottom: 16px;
    display: block;
}

.featured-image {
    width: 100%;
    max-height: 460px;
    object-fit: cover;
    border-radius: 22px;
    margin: 12px 0 24px;
    display: block;
}

.admin-image-preview {
    max-width: 260px;
    border-radius: 16px;
    display: block;
    margin: 8px 0 12px;
    border: 1px solid var(--border);
}

.nav-search {
    margin: 0;
}

.nav-search input {
    width: 155px;
    margin: 0;
    padding: 8px 11px;
    border-radius: 999px;
}

.search-page-form {
    display: flex;
    gap: 12px;
    align-items: end;
    max-width: 100%;
}

.search-page-form label {
    display: none;
}

.search-page-form input {
    margin-bottom: 0;
}

@media (max-width: 760px) {
    .nav-search,
    .nav-search input {
        width: 100%;
    }

    .search-page-form {
        display: block;
    }

    .search-page-form label {
        display: block;
    }

    .search-page-form input {
        margin-bottom: 16px;
    }
}

html.dark-mode .post-thumb,
html.dark-mode .featured-image,
html.dark-mode .admin-image-preview {
    border-color: #243044;
}


.html-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 10px 0 18px;
}

.html-source {
    display: none;
    width: 100%;
    min-height: 310px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre;
    tab-size: 4;
}

.dark-mode .html-source,
html.dark-mode .html-source {
    background: #0f172a !important;
    color: #e5e7eb !important;
    border-color: #243044 !important;
}


.site-footer {
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .75);
    margin-top: 40px;
}

.footer-inner {
    max-width: 1060px;
    margin: 0 auto;
    padding: 24px 22px;
    color: var(--muted);
    line-height: 1.6;
}

.footer-inner p {
    margin: 0;
}

html.dark-mode .site-footer {
    background: rgba(17, 24, 39, .88) !important;
    border-top-color: #243044 !important;
}

html.dark-mode .footer-inner,
html.dark-mode .footer-inner p,
html.dark-mode .footer-inner a {
    color: #94a3b8;
}


#comments table td:first-child {
    max-width: 420px;
    line-height: 1.45;
}


.admin-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 22px;
    position: sticky;
    top: 72px;
    z-index: 9;
    background: rgba(243, 245, 249, .88);
    backdrop-filter: blur(10px);
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
}

.admin-tab {
    background: #eef2ff;
    color: #3730a3;
    box-shadow: none;
}

.admin-tab.active {
    background: var(--brand);
    color: white;
    box-shadow: 0 10px 22px rgba(79, 70, 229, .22);
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

html.dark-mode .admin-tabs {
    background: rgba(15, 23, 42, .88) !important;
    border-color: #243044 !important;
}

html.dark-mode .admin-tab {
    background: #1e293b !important;
    color: #c7d2fe !important;
}

html.dark-mode .admin-tab.active {
    background: #818cf8 !important;
    color: #0f172a !important;
}

@media (max-width: 760px) {
    .admin-tabs {
        position: static;
    }

    .admin-tab {
        flex: 1 1 45%;
    }
}
