:root {
    --font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;

    /* General */
    --text-color: rgb(51, 51, 51);

    --link-color: #337ab7;
    --link-hover-color: #23527c;

    --text-muted-color: #777;

    --space-md: 1em;

    /* Sidebar */
    --sidebar-header-color: var(--text-color);

    --sidebar-social-color: #353535;
    --sidebar-taglist-color: #353535;

    --sidebar-taglist-hover-border-color: #666666;

    --sidebar-bg-color: #f5f5f5;
    --sidebar-taglist-hover-bg-color: #eeeeee;

    /* Header */

    --header-bg-color: #dadada;
    --navbar-items-bg-color: #c5c5c5;
    --navbar-items-hover-bg-color: rgb(231, 231, 231);

    /* Footer */
    --footer-bg-color: #eee;

    --footer-border-color: #999;

    /* Article */
    --article-meta-color: rgb(71, 71, 71);

    /* Code sample */
    --code-sample-border-color: #999;

    /* Pagination */
    --pagination-link-color: #353535;
    --pagination-link-hover-color: rgb(231, 231, 231);
    --pagination-border-color: rgb(231, 231, 231);
}

* {
    box-sizing: border-box;
}

/* General */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: var(--font-family);
    margin: 0;
    color: var(--text-color);
}

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

a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* Header */
body > header {
    background-color: var(--header-bg-color);
}

.navbar {
    display: grid;
    grid-template-columns: auto auto 1fr;
    width: 100%;
    margin: 0 auto;
    position: relative;
    min-height: 2.7rem;
}

.navbar .navbar-header-toggles {
    display: flex;
    justify-content: flex-end;
    grid-column-start: 3;
}

.navbar-header-toggles .nav-icon {
    display: inline-block;
    padding: var(--space-md) var(--space-md);
    cursor: pointer;
    user-select: none;
}

.navbar > .navbar-items {
    display: none;
    list-style: none;
    padding: var(--space-md) 0;
    margin: 0;

    background-color: var(--navbar-items-bg-color);
}

.navbar > .navbar-items > li {
    padding: 0;
}

.navbar .navbar-items > li a {
    display: block;
    color: var(--text-muted-color);
    font-size: 1em;
    font-weight: 700;
}

.navbar .navbar-items > li a:hover {
    background-color: var(--navbar-items-hover-bg-color);
    text-decoration: none;
}

.navbar .nav-button {
    display: none;
}

.navbar .nav-icon {
    align-content: center;
}

.navbar .nav-icon .nav-bars {
    background-color: var(--text-muted-color);
    display: block;
    position: relative;
    height: 2px;
    transition: all .2s ease-out;
    width: 22px
}

.navbar .nav-icon .nav-bars:after,
.navbar .nav-icon .nav-bars:before {
    content: "";
    background-color: var(--text-muted-color);
    display: block;
    position: absolute;
    height: 100%;
    transition: all .2s ease-out;
    width: 100%
}

.navbar .nav-icon .nav-bars:after {
    top: -6px
}

.navbar .nav-icon .nav-bars:before {
    top: 6px
}

.navbar .nav-button:checked ~ .nav-icon .nav-bars {
    background: transparent;
}

.navbar .nav-button:checked ~ .nav-icon .nav-bars:after,
.navbar .nav-button:checked ~ .nav-icon .nav-bars:before {
    top: 0;
}

.navbar .nav-button:checked ~ .nav-icon .nav-bars:after {
    transform: rotate(45deg);
}

.navbar .nav-button:checked ~ .nav-icon .nav-bars:before {
    transform: rotate(-45deg);
}

.navbar .nav-button:checked ~ .navbar-items {
    display: flex;
    justify-content: center;
    grid-row: 3;
    grid-column: 1 / 4;
}

.navbar .navbar-header {
    display: flex;
    flex-direction: column;
    font-size: 1.5em;
}

.navbar .navbar-header .navbar-home:hover {
    background-color: var(--navbar-items-hover-bg-color);
    text-decoration: none;
}

.navbar .navbar-home {
    display: inline-block;
    font-size: 1.4em;
    color: var(--text-muted-color);
    height: 100%;
    padding: 0.5em 0 0.5em 1.5em;
}

@media (min-width: 800px) {
    .navbar .nav-icon {
        display: none;
    }

    .navbar .navbar-items {
        padding-left: 2em;
        display: flex;
        justify-content: center;
        grid-column: 2 / 3 !important;
        grid-row: 1 / 2 !important;
        background-color: var(--header-bg-color);
    }
}

#wrapper {
    margin: 0 0;
    display: flex;
    flex: 1 1 auto;
}

/*Main container*/
#main-container {
    display: flex;
    width: 100%;
    flex-direction: column;
    flex: 1 1 auto;
}

#content {
    width: 90%;
    margin: 0 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    align-items: center;
}

#content > main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 100%;
    max-width: min(100%, 900px);

    padding-bottom: 1.5em;
}

/* Sidebar */
.sidebar {
    margin: 0;
    background-color: var(--sidebar-bg-color);
}

.sidebar .sidebar-content {
    width: 85%;
    margin: 0 auto;
}

.sidebar .sidebar-header,
.sidebar .sidebar-header:active {
    color: var(--sidebar-header-color);
}

.sidebar .sidebar-header {
    margin: 0;
    text-align: center;
    font-size: 1.3em;
    font-weight: 600;
}

.sidebar .sidebar-divider {
    margin: 2em 0;
    font-size: 0.5em;
}

/* Sidebar social */
.sidebar .sidebar-social {
    padding: 0;
    margin-top: 1em;
    margin-bottom: 1.5em;
    justify-content: space-evenly;
    display: flex;
}

.sidebar .sidebar-social li {
    list-style: none;
}

.sidebar .sidebar-social li a {
    width: 1.4em;
    height: 1.4em;
    display: flex;
    font-size: 1.8em;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--sidebar-social-color);
    color: var(--sidebar-social-color);
    position: relative;
    transition: border-radius 0.2s linear 0s;
}

.sidebar .sidebar-social li:not(:first-child) {
    margin-left: 2em;
}

.sidebar .sidebar-social li a:hover {
    border-style: dotted;
    text-decoration: none;
    opacity: 80%;
}

.sidebar .sidebar-social li a i {
    display: inline-block;
}

/* Sidebar taglist */

.sidebar .sidebar-taglist ul {
    display: flex;
    margin-top: 0.2em;
    justify-content: flex-start;
    row-gap: 0.3em;
    padding-left: 0.5em;
    font-size: 1.2em;
    flex-wrap: wrap;
    list-style-type: none;
}

.sidebar .sidebar-taglist ul li {
    margin: 0 0.1em;
    position: relative;
    font-size: 0.9em;
}

.sidebar .sidebar-taglist ul li a {
    display: inline-block;
    padding: 0.5em;
}

.sidebar .sidebar-taglist ul li > a {
    color: var(--sidebar-taglist-color);
}

.sidebar .sidebar-taglist ul li:hover a {
    border-color: var(--sidebar-taglist-hover-border-color);
    background-color: var(--sidebar-taglist-hover-bg-color);
    text-decoration: none;
}

@media only screen and (min-width: 768px) {
    #main-container {
        margin-left: 5%;
        flex-direction: row;
        align-items: stretch;
    }

    #content {
        flex-basis: 70%;
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        margin-left: 3%;
        flex-basis: 30%;
    }

    .sidebar-top-divider {
        display: none;
    }

    .sidebar .sidebar-box {
        padding-top: 0.6em;
    }

    .sidebar .sidebar-divider {
        margin: 2em 1.5em;
    }
}

@media only screen and (min-width: 1500px) {
    #content {
        flex-basis: 80%;
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        margin-left: 3%;
        flex-basis: 20%;
    }
}

/*Footer*/
body > footer {
    background-color: var(--footer-bg-color);
    border-top: 1px dotted var(--footer-border-color);
    text-align: center;
}

body > footer > address {
    font-size: 0.9rem;
    font-style: normal;
    color: #777;
}

/* Tags  */
.tags > h1 {
    font-size: 2em;
    margin: 0.4em 0 0.1em 0;
}

/* Tags */
.tags li {
    font-size: 1.8em;
}

article .article-title {
    font-size: 1.6em;
    margin-bottom: 0.1em;
}

article .article-info > p {
    padding: 0;
    margin: 0;
    color: var(--article-meta-color);
    font-size: 0.9em;
}

article .summary p {
    padding: 0;
    margin: 0.2em 0;
}

.highlight pre {
    display: block;
    overflow-x: auto;
    word-break: normal;
    word-wrap: normal;
    white-space: pre;

    border-left: 6px solid var(--code-sample-border-color);
    padding: 0.8em 1.2em;
    border-radius: 0.3em;
}

.pagination {
    display: flex;
    justify-content: space-between;
    margin-top: auto; /* push to bottom of the content column */
    padding: 1em 0;
    border-top: 1px solid var(--pagination-border-color);
}

.pagination a {
    border: 1px solid var(--pagination-link-color);
    color: var(--pagination-link-color);
    border-radius: 5%;
    padding: 0.5em 1em;
}

.pagination a:hover {
    background-color: var(--pagination-link-hover-color);
}

.pagination a i {
    vertical-align: center;
    font-size: 2.4em;
}

.pagination .next {
    margin-left: auto;
}

#comment-section {
    margin-top: 5em;
}

.page-content figure {
    text-align: center;
    padding: 0.5em 0;
}

.page-content img {
    max-width: 100%;
}

.page-content figure > figcaption {
    padding-top: 0.5em;
    font-size: 0.9em;
}

.footnotes p {
    margin: 0.2em 0;
}

/* Helpers */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

/* Dark mode and theme toggle additions */
/* Basic toggle button styling */
.theme-toggle {
    margin: 0 0.5rem;
    padding: 1em 0.6em;
    font-size: 0.9em;
    line-height: 1;
    border: none;
    background: transparent;
    cursor: pointer;
}

/* Mobile (default): make toggle look like other menu items */
.navbar .navbar-items > li .theme-toggle {
    display: block;
    width: 100%;
    float: left;
    color: var(--text-muted-color);
    text-align: left;
}

/* Hover to match anchors */
.navbar .navbar-items > li .theme-toggle:hover {
    background-color: var(--navbar-items-hover-bg-color);
}

.fas {
    display: inline-block;
}

/* Light theme default (overrides if needed) */
:root,
html[data-theme="light"] {
    color-scheme: light;
}

/* Dark theme overrides */
html[data-theme="dark"] {
    color-scheme: dark;

    --text-color: #e5e5e5;

    --link-color: #8ab4f8;
    --link-hover-color: #a9c7ff;

    --header-bg-color: #1a1a1a;

    --navbar-items-bg-color: #1a1a1a;
    --navbar-items-hover-bg-color: #222;

    --article-meta-color: rgb(177, 177, 177);

    --pagination-border-color: #333;
    --pagination-link-color: #ddd;
    --pagination-link-hover-color: #222;

    --sidebar-bg-color: #181818;
    --sidebar-social-color: #ddd;
    --sidebar-taglist-color: #ddd;;
    --sidebar-taglist-hover-border-color: #555;
    --sidebar-taglist-hover-bg-color: #222;

    --footer-bg-color: #1a1a1a;
}

html[data-theme="dark"] body {
    background-color: #121212;
}

/* Header/nav */

html[data-theme="dark"] .navbar .navbar-items {
    border-color: #333;
}

html[data-theme="dark"] .navbar .navbar-items > li a {
    color: #ccc;
}

html[data-theme="dark"] .navbar .nav-icon .nav-bars,
html[data-theme="dark"] .navbar .nav-icon .nav-bars:after,
html[data-theme="dark"] .navbar .nav-icon .nav-bars:before {
    background-color: #bbb;
}


/* Content basics */
html[data-theme="dark"] #content {
    color: #e5e5e5;
}

/* Sidebar */
html[data-theme="dark"] .sidebar .sidebar-divider {
    color: #666;
}

/* Sidebar social */
html[data-theme="dark"] .sidebar .sidebar-social li a:hover {
    border-color: #999;
    background-color: #202020;
}

/* Sidebar taglist */
html[data-theme="dark"] .sidebar .sidebar-taglist ul li > a {
    border-radius: 4px;
}

/* Article elements */
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3,
html[data-theme="dark"] h4, html[data-theme="dark"] h5, html[data-theme="dark"] h6 {
    color: #f0f0f0;
}

html[data-theme="dark"] blockquote {
    color: #cfcfcf;
    border-left-color: #333;
}

/* Tables, borders */
html[data-theme="dark"] table {
    color: #e5e5e5;
}

html[data-theme="dark"] th, html[data-theme="dark"] td {
    border-color: #333;
}

/* Code blocks (fallback; pygments CSS might also apply) */
html[data-theme="dark"] pre, html[data-theme="dark"] code {
    background-color: #141414;
    color: #e6e6e6;
}

/* Diagrams (puml generated) */
html[data-theme="dark"] .diagram img {
    filter: invert(100%) hue-rotate(180deg);
}

/* Pagination */


/* Footer */
html[data-theme="dark"] footer {
    color: #ccc;
}

/* Improve toggle contrast in dark */
html[data-theme="dark"] .theme-toggle {
    border-color: rgba(255, 255, 255, 0.25);
    color: #eee;
}

/* System preference fallback when JS disabled */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) body {
        background-color: #121212;
        color: #e5e5e5;
    }

    html:not([data-theme]) body > header {
        background-color: #1a1a1a;
    }

    html:not([data-theme]) .navbar .navbar-items {
        border-color: #333;
    }

    html:not([data-theme]) .navbar .navbar-items > li a {
        color: #ccc;
    }
}