:root {
    --accent: #111;
    --grey: #777;
    --border: #ddd;
    --bg: #fff;
    --fg: #333;
    --max-width: 44rem;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #eee;
        --border: #333;
        --bg: #111;
        --fg: #ccc;
    }
}

html[data-theme="light"] {
    --accent: #111;
    --grey: #777;
    --border: #ddd;
    --bg: #fff;
    --fg: #333;
}

html[data-theme="dark"] {
    --accent: #eee;
    --border: #333;
    --bg: #111;
    --fg: #ccc;
}

body {
    background: var(--bg);
    color: var(--fg);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Exo 2', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 1.5rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

svg {
    display: inline-block;
    vertical-align: middle;
}

a {
    color: var(--accent);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
}

/* Header */
.site-header {
    margin-bottom: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
}

.header-text {
    flex: 1;
}

.site-name {
    margin: 0;
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1.1;
}

.site-name a {
    color: inherit;
    text-decoration: none;
}

.site-name a:hover {
    text-decoration: underline;
}

.designation {
    margin: 0.25rem 0 0.75rem;
    font-size: 0.95rem;
    color: var(--grey);
}

/* Social icons */
.social-icons {
    display: flex;
    gap: 1.2rem;
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
}

.icon-red {
    color: var(--accent) !important;
}

.icon-grey {
    color: var(--grey) !important;
}

/* Navigation */
.site-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.92rem;
    margin-top: 0.75rem;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    text-decoration: none;
    white-space: nowrap;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* Photo */
.header-photo {
    flex-shrink: 0;
}

.profile-photo {
    width: 90px;
    height: 90px;
    display: block;
    border-radius: 50%;
    object-fit: cover;
}

/* Search bar */
.search-bar {
    display: none;
    padding: 0.5rem 0;
}

.search-bar.open {
    display: block;
}

.search-bar .search-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
    background: var(--bg);
    color: var(--fg);
}

/* Search toggle button */
.search-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.92rem;
    line-height: inherit;
    color: var(--grey);
    display: inline-flex;
    align-items: center;
}

.search-toggle:hover {
    color: var(--accent);
}

/* Divider */
.section-divider {
    border: none;
    border-top: 3px solid currentColor;
    margin: 2rem 0;
}

/* Posts */
.post-preview {
    margin-bottom: 2.5rem;
}

.post-title {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
}

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

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

.post-meta {
    margin: 0 0 0.25rem;
    font-size: 0.85rem;
    color: var(--grey);
    font-family: monospace;
}

.post-tags {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: var(--grey);
    font-family: monospace;
}

.post-tags a {
    color: var(--grey);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.post-tags a:hover {
    color: var(--accent);
}

.post-summary {
    font-size: 0.95rem;
    margin: 0.5rem 0 0;
}

.post-summary p {
    margin: 0;
}

.read-more {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
}

.read-more a {
    color: var(--accent);
    text-decoration: none;
}

.read-more a:hover {
    text-decoration: underline;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.9rem;
    margin: 1.5rem 0;
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
}

.pagination a:hover {
    text-decoration: underline;
}

.disabled {
    color: var(--grey);
}

/* Full post page */
.post-full .post-title {
    font-size: 1.6rem;
    color: var(--accent);
}

.content {
    line-height: 1.75;
    font-size: 0.95rem;
}

.content h2 { margin: 1.5rem 0 0.5rem; font-size: 1.2rem; }
.content h3 { margin: 1.25rem 0 0.5rem; font-size: 1.05rem; }
.content p { margin: 0 0 0.75rem; }
.content ul, .content ol { padding-left: 1.5rem; margin: 0 0 0.75rem; }
.content li { margin: 0.2rem 0; }

/* Syntax highlighting */
pre.giallo {
    overflow-x: auto;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    line-height: 1.45;
    font-family: monospace;
    background: var(--bg) !important;
    color: var(--fg) !important;
}

.giallo-l {
    display: inline-block;
    min-height: 1lh;
    width: 100%;
}

.giallo-ln {
    display: inline-block;
    user-select: none;
    margin-right: 0.4em;
    padding: 0.4em;
    min-width: 3ch;
    text-align: right;
    opacity: 0.8;
}

.content code {
    padding: 0.1rem 0.3rem;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 0.88em;
    font-family: monospace;
}

pre.giallo code {
    padding: 0;
    border: none;
    background: none;
}

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

.content blockquote {
    margin: 1.5rem 0;
    padding: 0.5rem 1rem;
    border-left: 3px solid var(--accent);
    color: var(--fg);
    font-style: italic;
    opacity: 0.8;
}

.note-content blockquote {
    margin: 1.5rem 0;
    padding: 0.5rem 1rem;
    border-left: 3px solid var(--accent);
    color: var(--fg);
    font-style: italic;
    opacity: 0.8;
}

/* Section page */
.section-page h1 {
    font-size: 1.5rem;
    margin: 0 0 1rem;
}

.entry-list {
    padding-left: 1.5rem;
}

.entry-list li {
    margin: 0.4rem 0;
}

/* Footer */
.site-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--grey);
    line-height: 1.8;
}

.site-footer a {
    color: var(--accent);
}

.site-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    body { padding: 0.75rem; }
    .site-name { font-size: 1.6rem; }
    .profile-photo { width: 60px; height: 60px; }
    .header-content { gap: 1rem; }
    .social-icons { font-size: 1rem; }
}

/* ===== Portfolio / Accordion ===== */

.portfolio {
    font-family: monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.portfolio-section {
    margin: 0;
}

.portfolio-note {
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    color: var(--grey);
}

.note-content p {
    margin: 0;
}

.section-heading {
    font-family: monospace;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 0.5rem;
    color: var(--accent);
}

/* Accordion */
.accordion {
    margin: 0;
}

.accordion-item {
    border-bottom: 1px solid var(--border);
}

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

.accordion-header {
    display: grid;
    grid-template-columns: 1.2em 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 0.5rem;
    row-gap: 0;
    align-items: baseline;
    width: 100%;
    padding: 0.5rem 0;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: monospace;
    font-size: inherit;
    color: var(--fg);
    line-height: 1.4;
}

.accordion-header:hover {
    color: var(--accent);
}

.accordion-header:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.accordion-chevron {
    grid-row: 1;
    grid-column: 1;
    align-self: center;
    font-size: 0.7rem;
    color: var(--grey);
    transition: transform 0.2s ease;
    line-height: 1;
}

.accordion-item.open .accordion-chevron {
    transform: rotate(90deg);
}

.accordion-title {
    grid-row: 1;
    grid-column: 2;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent);
}

.accordion-subtitle {
    grid-row: 2;
    grid-column: 2 / -1;
    font-size: 0.8rem;
    color: var(--grey);
}

.accordion-date {
    grid-row: 1;
    grid-column: 3;
    font-size: 0.75rem;
    color: var(--grey);
    white-space: nowrap;
    padding-left: 1rem;
    align-self: center;
}

.accordion-header-link {
    color: var(--grey);
    text-decoration: none;
    display: inline;
    vertical-align: middle;
}

.accordion-header-link:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.accordion-header-link svg {
    width: 0.8em;
    height: 0.8em;
    vertical-align: middle;
    margin-right: 0.15em;
}

.header-link-sep {
    color: var(--grey);
    opacity: 0.4;
    margin: 0 0.4em;
    user-select: none;
}

/* Accordion panel (expandable content) */
.accordion-panel {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease;
}

.accordion-body {
    padding: 0 0 0.75rem calc(1.2em + 0.5rem);
    font-size: 0.825rem;
    color: var(--fg);
}

.accordion-body p {
    margin: 0 0 0.4rem;
}

.accordion-body ul {
    margin: 0.25rem 0;
    padding-left: 1.2rem;
}

.accordion-body li {
    margin: 0.15rem 0;
}

.accordion-tech {
    margin: 0 0 0.5rem !important;
    font-size: 0.8rem;
    color: var(--grey);
}

.accordion-tech strong {
    color: var(--fg);
    font-weight: 600;
}

.accordion-description {
    margin: 0.25rem 0;
}

.accordion-description p {
    margin: 0 0 0.3rem;
}

.accordion-links {
    margin: 0.5rem 0 0 !important;
    font-size: 0.8rem;
}

.accordion-link {
    color: var(--grey);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.accordion-link:hover {
    color: var(--accent);
}

/* Contact section */
.contact-content {
    font-size: 0.85rem;
    padding: 0.5rem 0;
}

.contact-content p {
    margin: 0.25rem 0;
}

.contact-content a {
    color: var(--grey);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.contact-content a:hover {
    color: var(--accent);
}

@media (max-width: 600px) {
    .accordion-header {
        grid-template-columns: 1.2em 1fr auto;
        font-size: 0.85rem;
    }
    .accordion-title {
        font-size: 0.85rem;
    }
    .accordion-date {
        font-size: 0.7rem;
    }
    .accordion-body {
        padding-left: 0;
    }
    .portfolio {
        font-size: 0.85rem;
    }
}
