:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --text: #222222;
    --muted: #555555;
    --border: #cccccc;
    --chip-bg: #f0f0f0;
    --card-border: #e5e7eb;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg);
    color: var(--text);
}

.main {
    box-sizing: content-box;
    width: 100%;
    max-width: 900px;
    padding: 20px;
}

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
    height: auto;
}

.logo {
    font-size: 1.44em;
    font-weight: normal;
    font-family: "Helvetica Neue", sans-serif;
}

header .logo {
    font-weight: bold;
}

nav {
    display: flex;
    gap: 20px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

nav a {
    text-decoration: none;
    color: #333;
    font-weight: normal;
    position: relative;
}

nav a::after {
    content: "";
    display: block;
    width: 0;
    height: 2px;
    background: #333;
    transition: width 0.3s;
    position: absolute;
    bottom: -5px;
    left: 0;
}

header .logo,
header nav {
    display: flex;
    align-items: center;
}

nav a:hover::after,
nav a.active::after,
nav a[aria-current="page"]::after {
    width: 100%;
}

.profile-pic {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin: 20px auto;
    display: block;
    border: 3px solid #ddd;
}

.section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #333;
    font-weight: bold;
}

.section-content {
    font-size: 0.9em;
    line-height: 1.6;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.section-content .item {
    display: flex;
    gap: 20px;
}

.section-content .item .logo {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 5px;
}

.section-content .item .text {
    flex-grow: 1;
    margin-bottom: 5px;
}

.section-content ul {
    list-style-type: disc;
    padding-left: 20px;
}

.section-content ul li {
    margin: 5px 0;
}

.section-content .item ul {
    margin-top: 5px;
    margin-bottom: 5px;
}

.skills {
    display: block;
}

.skills ul {
    list-style-type: disc;
    padding-left: 1.25rem;
    margin: 0;
}

.skills ul li {
    margin: 0.2rem 0;
    line-height: 1.42;
}

#skills .section-title {
    margin-bottom: 6px;
}

.projects-section {
    width: 100%;
    margin-bottom: 28px;
}

.projects-title {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 14px;
    text-align: center;
}

.project-category {
    margin-bottom: 0;
}

.project-category h2 {
    font-size: 1.2em;
    margin-bottom: 14px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
}

.project-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.project-card:hover {
    transform: translateY(-5px);
}

.project-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    cursor: pointer;
}

.project-content {
    padding: 11px 12px 12px;
}

a.project-card-heading-link {
    text-decoration: none;
    color: inherit;
    display: block;
    cursor: pointer;
}

a.project-card-heading-link:hover .project-title {
    text-decoration: underline;
}

a.project-card-heading-link:focus-visible {
    outline: 2px solid var(--border);
    outline-offset: 3px;
    border-radius: 4px;
}

.project-title {
    font-size: 1em;
    font-weight: bold;
    margin: 0 0 6px;
    line-height: 1.28;
}

.project-date {
    font-size: 0.85em;
    color: var(--muted);
    margin: 0 0 9px;
    line-height: 1.35;
}

.project-description {
    font-size: 0.9em;
    color: var(--muted);
    margin: 0 0 10px;
    line-height: 1.45;
}

.project-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.project-keywords span {
    background-color: var(--chip-bg);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.85em;
}

footer {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.footer-left img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
}

.footer-icons {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.footer-icons a img {
    width: 25px;
    height: 25px;
}

.footer-right {
    display: flex;
    flex-direction: column;
    text-align: right;
    gap: 5px;
}

.footer-right a {
    text-decoration: none;
    color: #333;
    font-weight: normal;
    font-family: "Helvetica Neue", sans-serif;
    transition: opacity 0.3s ease;
}

.footer-right a:hover {
    opacity: 0.6;
}

.footer-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.footer-details .name {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
    font-family: "Helvetica Neue", sans-serif;
}

.footer-details .title {
    font-size: 1em;
    font-weight: normal;
    margin: 0;
    color: var(--muted);
    font-family: "Helvetica Neue", sans-serif;
}

/* --- Project detail pages (projects/project*.html) --- */
.project-detail-page {
    width: 100%;
}

.project-detail-page .project-detail-heading {
    font-size: 1.35rem;
    line-height: 1.3;
    margin: 0 0 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.project-detail-page h2.section-title {
    margin-top: 0.75rem;
    margin-bottom: 0;
}

.project-detail-page h2.section-title:first-child {
    margin-top: 0;
}

.project-detail-page .section-content {
    gap: 8px;
}

.project-detail-page .section-content > p {
    margin: 0;
}

.project-detail-page .section-content ul {
    margin: 0;
    padding-left: 1.25rem;
}

.project-detail-page .section-content ul li {
    margin: 2px 0;
}

.project-detail-page .project-detail-meta {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: var(--muted);
}

.project-detail-page .project-detail-tags {
    margin-bottom: 8px;
}

.project-detail-page .project-detail-media {
    margin: 12px 0;
    text-align: center;
}

.project-detail-page .project-detail-img {
    width: auto;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    vertical-align: middle;
}

.project-detail-page .project-detail-media--sm .project-detail-img {
    max-width: min(42%, 380px);
}

.project-detail-page .project-detail-media--md .project-detail-img {
    max-width: min(72%, 640px);
}

.project-detail-page .project-detail-media--lg .project-detail-img {
    max-width: min(96%, 840px);
}

.project-detail-page .project-detail-github img {
    display: block;
    width: 28px;
    height: 28px;
}

.project-detail-page .section-content h3 {
    font-size: 1.05rem;
    margin: 0;
    color: var(--text);
}

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    font-size: 0.95rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.theme-toggle:hover {
    opacity: 0.85;
}

@media (max-width: 640px) {
    :root {
        --mobile-card-border: 1px solid var(--card-border);
        --mobile-card-radius: 12px;
        --mobile-card-padding: 14px;
        --mobile-card-bg: var(--surface);
    }

    body {
        background: var(--bg);
        overflow-x: hidden;
    }

    .main {
        box-sizing: border-box;
        min-width: 0;
        max-width: 100%;
        padding-top: max(14px, env(safe-area-inset-top, 0px));
        padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(14px, env(safe-area-inset-right, 0px));
    }

    header,
    .section,
    .projects-section,
    footer {
        width: 100%;
        box-sizing: border-box;
        padding: var(--mobile-card-padding);
        border: var(--mobile-card-border);
        border-radius: var(--mobile-card-radius);
        background: var(--mobile-card-bg);
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin: 0 0 14px 0;
        border-bottom: var(--mobile-card-border);
    }

    .logo {
        font-size: 1.4rem;
        line-height: 1.1;
    }

    nav {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .header-controls {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 8px;
    }

    nav a {
        text-align: center;
        padding: 7px 6px;
        border: 1px solid var(--card-border);
        border-radius: 999px;
        font-size: 0.88rem;
    }

    nav a::after {
        display: none;
    }

    .profile-pic {
        width: 132px;
        height: 132px;
        margin: 10px auto 14px;
    }

    .section {
        margin: 0 0 14px 0;
    }

    .section-title {
        margin: 0 0 10px;
        font-size: 1.35rem;
        line-height: 1.25;
    }

    .section-content {
        font-size: 1rem;
        line-height: 1.7;
        gap: 12px;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .section-content .item {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr);
        gap: 12px;
        align-items: start;
    }

    .section-content .item .logo {
        width: 44px;
        height: 44px;
        margin-top: 2px;
    }

    .section-content .item .text {
        min-width: 0;
        font-size: 0.98rem;
    }

    .section-content ul {
        padding-left: 18px;
    }

    .skills {
        display: block;
    }

    .skills ul li {
        margin: 4px 0;
        line-height: 1.42;
    }

    .projects-section {
        margin-bottom: 14px;
    }

    .projects-title {
        margin: 0 0 10px;
        font-size: 1.45rem;
        text-align: left;
    }

    .project-category {
        margin: 0;
    }

    .projects-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .project-card {
        border: 1px solid var(--card-border);
        border-radius: 10px;
        box-shadow: none;
    }

    .project-card:hover {
        transform: none;
    }

    .project-image {
        height: 170px;
    }

    .project-content {
        padding: 11px 12px 12px;
    }

    .project-title {
        font-size: 1.02rem;
        line-height: 1.26;
        margin: 0 0 6px;
    }

    .project-date {
        margin: 0 0 9px;
    }

    .project-description {
        font-size: 0.95rem;
        line-height: 1.45;
        margin: 0 0 10px;
    }

    .project-keywords {
        gap: 6px;
    }

    .project-keywords span {
        font-size: 0.8rem;
        padding: 4px 8px;
    }

    footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin: 0;
        border-top: var(--mobile-card-border);
        max-width: 100%;
    }

    .footer-left {
        width: 100%;
        gap: 12px;
    }

    .footer-left img {
        width: 68px;
        height: 68px;
    }

    .footer-right {
        width: 100%;
        text-align: left;
        align-items: flex-start;
        padding-top: 4px;
    }

    .project-detail-page .project-detail-media--sm .project-detail-img,
    .project-detail-page .project-detail-media--md .project-detail-img,
    .project-detail-page .project-detail-media--lg .project-detail-img {
        max-width: 100%;
    }
}

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"]:root {
    --bg: #0f1115;
    --surface: #161a21;
    --text: #e5e7eb;
    --muted: #b8c0cc;
    --border: #2b3340;
    --chip-bg: #202735;
    --card-border: #2f3a4a;
}

html[data-theme="dark"] nav a,
html[data-theme="dark"] .footer-right a,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .projects-title,
html[data-theme="dark"] .project-title {
    color: var(--text);
}

html[data-theme="dark"] nav a::after {
    background: var(--text);
}

html[data-theme="dark"] .project-card {
    background: var(--surface);
}

html[data-theme="dark"] .project-detail-page .section-content h3 {
    color: var(--text);
}

@media (max-width: 640px) {
    html[data-theme="dark"]:root {
        --bg: #0f1115;
        --surface: #171b22;
        --text: #e8edf5;
        --muted: #c0c8d4;
        --border: #303a49;
        --chip-bg: #212a38;
        --card-border: #2f3a4a;
    }

    html[data-theme="dark"] {
        color-scheme: dark;
    }
}

/* 404 page */
.error-page {
    text-align: center;
    padding: 2.5rem 0 3rem;
    max-width: 28rem;
    margin: 0 auto;
}

.error-page-code {
    font-size: clamp(3rem, 12vw, 5rem);
    font-weight: 700;
    line-height: 1;
    margin: 0 0 0.75rem;
    color: var(--muted);
    letter-spacing: -0.02em;
}

.error-page-title {
    margin-top: 0;
    margin-bottom: 1rem;
}

.error-page-lead {
    color: var(--muted);
    margin: 0 0 1.5rem;
}

.error-page-actions {
    margin: 0;
    font-size: 1.05rem;
}

.error-page-actions a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.error-page-actions a:hover,
.error-page-actions a:focus-visible {
    opacity: 0.85;
}

.error-page-sep {
    margin: 0 0.35rem;
    color: var(--muted);
}

html[data-theme="dark"] .error-page-code {
    color: var(--muted);
}
