:root {
    --paper: #fbf7f0;
    --ink: #111111;
    --muted: #4a4a4a;
    --soft: #7a7a7a;
    --line: #111111;
    --accent: #ff6631;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 18px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

a:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
    border-radius: 2px;
}

.page {
    margin: 0 auto;
    max-width: 680px;
    padding: 36px 22px 28px;
}

/* Header / Nav */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.site-nav {
    display: flex;
    gap: 8px;
    width: 100%;
    font-family: "Patrick Hand", "Atkinson Hyperlegible", cursive;
    font-size: 17px;
    font-weight: 400;
    color: var(--muted);
    flex-wrap: wrap;
}

.site-nav a,
.site-nav button {
    color: inherit;
    padding: 4px 2px;
    transition: all 0.2s ease;
    font: inherit;
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: transparent;
    text-underline-offset: 4px;
}

.site-nav .brand {
    font-size: 22px;
    color: var(--ink);
    letter-spacing: 0.01em;
}

.site-nav a:first-child {
    margin-right: auto;
}

.site-nav a + a,
.site-nav a + form,
.site-nav form + a {
    margin-left: 14px;
}

.site-nav a:hover,
.site-nav button:hover {
    color: var(--ink);
    text-decoration-color: var(--ink);
    transform: rotate(-1deg);
}

.site-nav form {
    margin: 0;
}

/* Typography */
h1, h2, h3 {
    font-family: "Patrick Hand", "Atkinson Hyperlegible", cursive;
    font-weight: 400;
    line-height: 1.1;
    color: var(--ink);
}

h1 {
    font-size: clamp(38px, 6vw, 52px);
    margin-bottom: 18px;
}

h2 {
    font-size: 22px;
    margin: 0 0 14px;
    display: inline-block;
}

h3 {
    font-size: 26px;
    margin: 32px 0 14px;
}

p {
    margin-bottom: 18px;
}

.intro {
    font-size: clamp(18px, 2.2vw, 21px);
    line-height: 1.5;
    color: var(--muted);
    margin-bottom: 42px;
    max-width: 560px;
}

.section-description {
    font-size: 16px;
    color: var(--muted);
    margin-bottom: 18px;
    max-width: 560px;
}

/* Sections */
section {
    margin-bottom: 42px;
}

.section-heading {
    display: inline-block;
    position: relative;
    margin-bottom: 14px;
}

.section-heading h2 {
    margin: 0;
}

.section-heading::after {
    content: "";
    display: block;
    width: 100%;
    height: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 12' preserveAspectRatio='none'%3E%3Cpath d='M0,6 C30,2 70,10 100,6 C130,2 170,10 200,6 C230,2 270,10 300,6 C330,2 370,10 400,6 C430,2 470,10 500,6 C530,2 570,10 600,6' fill='none' stroke='%23111111' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    margin-top: 4px;
    opacity: 0.6;
}

/* Hand-drawn divider */
.sketch-divider {
    width: 100%;
    height: 10px;
    margin: 0 0 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 12' preserveAspectRatio='none'%3E%3Cpath d='M0,6 C30,2 70,10 100,6 C130,2 170,10 200,6 C230,2 270,10 300,6 C330,2 370,10 400,6 C430,2 470,10 500,6 C530,2 570,10 600,6' fill='none' stroke='%23111111' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border: 0;
    opacity: 0.5;
}

/* Detail page more-section */
.section-label {
    font-family: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 17px;
    color: var(--muted);
    margin-bottom: 8px;
}

.all-link-wrap {
    margin: 0 0 18px;
}

.all-link {
    font-family: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 17px;
    color: var(--ink);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: var(--ink);
    text-underline-offset: 4px;
    transition: all 0.2s ease;
}

.all-link:hover {
    transform: rotate(-1deg);
}

.wavy-underline {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 6' preserveAspectRatio='none'%3E%3Cpath d='M0,3 C5,1 10,5 15,3 C20,1 25,5 30,3' fill='none' stroke='%23111111' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-position: 0 100%;
    background-size: 18px 6px;
    padding-bottom: 4px;
}

/* GitHub contribution graph */
.contribution-graph {
    overflow-x: auto;
    margin-bottom: 18px;
    padding-bottom: 4px;
}

.contribution-graph table {
    border-collapse: separate;
    border-spacing: 3px;
    font-family: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 12px;
    color: var(--soft);
}

.contribution-graph td {
    padding: 0;
    line-height: 1;
}

.contribution-graph .graph-spacer {
    width: 28px;
}

.contribution-graph .month-label {
    text-align: left;
    padding-bottom: 4px;
    white-space: nowrap;
}

.contribution-graph .day-label {
    text-align: right;
    padding-right: 6px;
    vertical-align: middle;
    width: 28px;
}

.contribution-graph .activity-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background-color: #d8d4cc;
    border: 0;
}

.contribution-graph .activity-cell.level-1 { background-color: #b0b0b0; }
.contribution-graph .activity-cell.level-2 { background-color: #808080; }
.contribution-graph .activity-cell.level-3 { background-color: #505050; }
.contribution-graph .activity-cell.level-4 { background-color: var(--ink); }

/* Lists */
.index-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.index-list li {
    padding: 10px 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.index-list .thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--ink);
    border-radius: 4px;
    filter: grayscale(100%) contrast(1.1);
}

.index-list .thumb-placeholder {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: 2px solid var(--ink);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 400;
    color: var(--ink);
    text-transform: uppercase;
    transform: rotate(-2deg);
}

.index-list .item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
}

.index-list .item-content > div {
    min-width: 0;
}

.index-list .item-description {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.4;
    margin: 4px 0 0;
    font-weight: 400;
}

.index-list a {
    color: var(--accent);
    font-weight: 400;
    font-size: 17px;
    transition: all 0.2s ease;
    display: inline-block;
    text-decoration: none;
}

.index-list a:hover {
    color: var(--ink);
    transform: rotate(-1deg);
}

.index-list .meta {
    font-family: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.index-list .empty {
    color: var(--soft);
    font-size: 17px;
    font-weight: 400;
}

/* Filters */
.filters {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.filter {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    padding: 4px 2px;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: transparent;
    text-underline-offset: 4px;
}

.filter:hover {
    color: var(--ink);
    text-decoration-color: var(--ink);
    transform: rotate(-1deg);
}

.filter.active {
    color: var(--ink);
    text-decoration-color: var(--ink);
}

/* Article content */
article header {
    margin-bottom: 32px;
}

article .article-meta {
    font-size: 14px;
    color: var(--soft);
    margin-bottom: 14px;
}

article .article-meta span {
    margin-right: 16px;
}

article .excerpt {
    font-size: 19px;
    color: var(--muted);
    line-height: 1.5;
    max-width: 600px;
}

.prose {
    color: var(--muted);
    font-size: 17px;
    line-height: 1.7;
}

.prose > * {
    margin-bottom: 18px;
}

.prose h2 {
    font-family: "Patrick Hand", cursive;
    font-size: clamp(28px, 4vw, 36px);
    font-weight: 400;
    margin: 36px 0 16px;
}

.prose h3 {
    font-family: "Patrick Hand", cursive;
    font-size: 24px;
    font-weight: 400;
    margin: 28px 0 12px;
}

.prose ul, .prose ol {
    margin-bottom: 18px;
    padding-left: 28px;
}

.prose li {
    margin-bottom: 10px;
}

.prose a {
    color: var(--ink);
    font-weight: 700;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: var(--ink);
    text-underline-offset: 4px;
}

.prose a:hover {
    transform: rotate(-1deg);
}

.prose blockquote {
    border-left: 3px solid var(--ink);
    padding-left: 20px;
    margin: 28px 0;
    color: var(--soft);
    font-style: italic;
}

.prose code {
    font-family: inherit;
    font-size: 14px;
    background: rgba(17, 17, 17, 0.06);
    padding: 2px 8px;
    border-radius: 3px;
    color: var(--ink);
}

.prose pre {
    background: var(--ink);
    color: var(--paper);
    padding: 20px;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 18px;
}

.prose pre code {
    background: none;
    padding: 0;
    color: var(--paper);
}

.prose img {
    max-width: 100%;
    border: 2px solid var(--ink);
    border-radius: 4px;
    margin: 24px 0;
    display: block;
    filter: grayscale(100%) contrast(1.05);
}

/* Article-specific figure */
.figure {
    margin: 24px 0;
    border: 2px solid var(--ink);
    border-radius: 4px;
    overflow: hidden;
}

.figure img {
    display: block;
    width: 100%;
    height: auto;
    filter: grayscale(100%) contrast(1.05);
}

/* Back link */
.back-link {
    display: inline-block;
    font-size: 14px;
    color: var(--soft);
    margin-bottom: 24px;
    font-weight: 700;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: transparent;
    text-underline-offset: 4px;
}

.back-link:hover {
    color: var(--ink);
    text-decoration-color: var(--ink);
    transform: translateX(-3px);
}

/* Staff actions */
.staff-actions {
    margin-top: 24px;
    padding-top: 20px;
    position: relative;
    opacity: 0.6;
}

.staff-actions::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 12' preserveAspectRatio='none'%3E%3Cpath d='M0,6 C30,2 70,10 100,6 C130,2 170,10 200,6 C230,2 270,10 300,6 C330,2 370,10 400,6 C430,2 470,10 500,6 C530,2 570,10 600,6' fill='none' stroke='%23111111' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    opacity: 0.5;
}

.staff-edit {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--soft);
    transition: color 0.2s ease;
}

.staff-edit:hover {
    color: var(--ink);
}

/* Newsletter / Contact */
.newsletter-label {
    font-size: 14px;
    color: var(--soft);
    margin-bottom: 12px;
    font-weight: 700;
}

.newsletter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.newsletter-form input[type="text"],
.newsletter-form input[type="email"] {
    flex: 1 1 180px;
    min-width: 140px;
    font: inherit;
    font-size: 15px;
    padding: 10px 12px;
    border: 2px solid var(--ink);
    border-radius: 3px;
    background: var(--paper);
    color: var(--ink);
}

.newsletter-form input:focus {
    outline: none;
    border-width: 3px;
    transform: rotate(-0.5deg);
}

.newsletter-form button {
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 22px;
    background: var(--paper);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.newsletter-form button:hover {
    background: var(--ink);
    color: var(--paper);
    transform: rotate(-2deg) scale(1.02);
}

.newsletter-message {
    font-size: 14px;
    margin-top: 12px;
    color: var(--muted);
}

.newsletter-message.error {
    color: #c0392b;
}

.newsletter-form .cf-turnstile {
    flex-basis: 100%;
    margin-top: 8px;
}

.hidden {
    display: none;
}

/* CTA */
.cta-section {
    margin-top: 48px;
}

.cta {
    font-size: 17px;
    color: var(--ink);
    margin: 0 0 8px;
}

.cta-action {
    margin: 0;
}

.email-link {
    font-size: 16px;
    color: var(--accent);
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: var(--accent);
    text-underline-offset: 4px;
}

.email-link:hover {
    color: var(--ink);
    text-decoration-color: var(--ink);
    transform: rotate(-1deg);
}

/* Login */
.login-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.login-box {
    width: 100%;
    max-width: 400px;
    border: 2px solid var(--ink);
    padding: 32px;
    border-radius: 4px;
}

.login-box h1 {
    margin-bottom: 24px;
}

.error-msg {
    border: 2px solid var(--ink);
    color: var(--ink);
    padding: 12px 16px;
    border-radius: 3px;
    font-size: 14px;
    margin-bottom: 20px;
    background: rgba(17, 17, 17, 0.04);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 6px;
    color: var(--ink);
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--ink);
    border-radius: 3px;
    font-size: 16px;
    font-family: inherit;
    background: var(--paper);
    color: var(--ink);
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-width: 3px;
    transform: rotate(-0.5deg);
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: var(--paper);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: 3px;
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--ink);
    color: var(--paper);
    transform: rotate(-2deg) scale(1.02);
}

/* Project detail */
.project-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
}

.external-link {
    color: var(--ink);
    font-weight: 800;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: var(--ink);
    text-underline-offset: 4px;
}

.external-link:hover {
    transform: rotate(-1deg);
}

/* Footer */
.site-footer {
    color: var(--soft);
    font-size: 14px;
    margin-top: 32px;
    padding-top: 18px;
    position: relative;
    opacity: 0.7;
}

.footer-link {
    display: inline-block;
    margin-top: 4px;
    color: var(--soft);
    font-size: 14px;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
}

.footer-link:hover {
    color: var(--ink);
    text-decoration-color: var(--soft);
}

.site-footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 12' preserveAspectRatio='none'%3E%3Cpath d='M0,6 C30,2 70,10 100,6 C130,2 170,10 200,6 C230,2 270,10 300,6 C330,2 370,10 400,6 C430,2 470,10 500,6 C530,2 570,10 600,6' fill='none' stroke='%23111111' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    opacity: 0.5;
}

/* Links hub */
.links-hub {
    text-align: center;
    max-width: 320px;
    margin: 0 auto;
    padding-top: 24px;
}

.links-avatar {
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    border: 2px solid var(--ink);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transform: rotate(-2deg);
}

.avatar-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.links-name {
    font-family: "Patrick Hand", "Atkinson Hyperlegible", cursive;
    font-size: clamp(32px, 6vw, 42px);
    margin-bottom: 6px;
}

.links-subtitle {
    font-size: 16px;
    color: var(--muted);
    margin-bottom: 24px;
}

.links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.links-button {
    display: grid;
    grid-template-columns: 24px auto;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--ink);
    border-radius: 4px;
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.link-icon-wrap {
    width: 24px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.links-button:hover {
    background: var(--ink);
    color: var(--paper);
    transform: rotate(-1deg) scale(1.02);
}

.links-button:hover .link-icon {
    filter: invert(1);
}

.link-icon {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Mobile */
@media (max-width: 720px) {
    body {
        font-size: 17px;
    }

    .page {
        padding: 24px 18px 20px;
    }

    .site-header {
        margin-bottom: 36px;
    }

    .brand {
        font-size: 22px;
    }

    .site-nav {
        gap: 6px;
        font-size: 16px;
    }

    .site-nav a + a,
    .site-nav a + form,
    .site-nav form + a {
        margin-left: 10px;
    }

    h1 {
        font-size: 32px;
        margin-bottom: 14px;
    }

    h2 {
        font-size: 20px;
    }

    .intro {
        font-size: 17px;
        margin-bottom: 36px;
    }

    section {
        margin-bottom: 36px;
    }

    .sketch-divider {
        margin-bottom: 36px;
    }

    .index-list li {
        gap: 12px;
        padding: 10px 0;
    }

    .index-list .thumb,
    .index-list .thumb-placeholder {
        width: 40px;
        height: 40px;
    }

    .index-list .thumb-placeholder {
        font-size: 18px;
    }

    .index-list .item-content {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: baseline;
        gap: 12px;
    }

    .index-list .item-description {
        font-size: 13px;
    }

    .prose {
        font-size: 16px;
    }

    .prose ul, .prose ol {
        padding-left: 22px;
    }

    .prose pre {
        padding: 16px;
    }

    .newsletter-form button {
        width: 100%;
    }

    .site-footer {
        margin-top: 28px;
    }

    .login-box {
        padding: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
