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

:root {
    --bg: #DEDED6;
    --panel: #F0F0ED;
    --text: #1A1A18;
    --muted: #686862;
    --line: #BCBCB3;
    --accent: #4A7C59;
    --accent-dark: #345B40;
    --danger: #9B3D30;
    --font: "IBM Plex Sans", sans-serif;
    --mono: "IBM Plex Mono", monospace;
    --home-card-width: 188px;
    --home-carousel-gap: 0.75rem;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: var(--font);
    background:
        linear-gradient(90deg, rgba(26, 26, 24, 0.035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(26, 26, 24, 0.025) 1px, transparent 1px),
        var(--bg);
    background-size: 32px 32px;
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.75rem;
}

.terminal {
    background: var(--panel);
    border: 1px solid var(--text);
    box-shadow: 10px 10px 0 rgba(26, 26, 24, 0.08);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}

.brand__name {
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    text-transform: lowercase;
    white-space: nowrap;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    list-style: none;
}

.nav a {
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.75rem;
    opacity: 0.55;
    text-decoration: none;
}

.nav a:hover,
.nav a:focus-visible {
    color: var(--accent);
    opacity: 1;
    outline: none;
}

.hero {
    padding: clamp(2.5rem, 8vw, 5.5rem) 1.25rem 2rem;
    border-bottom: 1px solid var(--line);
}

.hero--page {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 11.5rem;
    padding: 2.5rem 1.25rem 2rem;
}

.hero--page .hero__title {
    font-family: var(--mono);
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.hero--page .hero__lead {
    max-width: 48ch;
    min-height: 3rem;
    margin-top: 1rem;
    font-size: 1rem;
    line-height: 1.5;
}

.hero--page-no-lead {
    min-height: auto;
    padding-bottom: 2rem;
}

.hero__title {
    max-width: none;
    font-family: var(--mono);
    font-size: clamp(1.75rem, 6vw, 3.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.hero__lead {
    max-width: 42ch;
    margin-top: 1.25rem;
    color: var(--muted);
    font-size: clamp(1rem, 2vw, 1.125rem);
}

.section {
    padding: 1.25rem;
    border-bottom: 1px solid var(--line);
}

.section:last-child {
    border-bottom: 0;
}

.section__head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section__title {
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.section__link,
.button-link {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
}

.section__link:hover,
.button-link:hover {
    color: var(--accent-dark);
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.grid--projects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#latest-projects.grid {
    grid-template-columns: 1fr;
}

.project-card {
    display: grid;
    grid-template-columns: minmax(220px, 36%) minmax(0, 1fr);
    align-items: start;
    border: 1px solid var(--text);
    background: var(--panel);
    color: inherit;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.project-card--list {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
}

.project-card--list .project-card__top {
    display: grid;
    grid-template-columns: minmax(220px, 36%) minmax(0, 1fr);
    align-items: start;
    border-bottom: 1px solid var(--line);
}

.project-card--list .project-card__image {
    border: 0;
}

.project-card--list .project-card__intro {
    min-width: 0;
    padding: 1rem;
}

.project-card--list .project-card__title {
    display: -webkit-box;
    margin: 0 0 0.35rem;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
}

.project-card--list .project-card__summary {
    margin: 0.35rem 0 0;
    color: var(--muted);
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.92rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.project-card--list .project-card__foot {
    padding: 0.65rem 1rem;
}

.project-card--list .project-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.project-card--list .tag-list {
    margin-top: 0;
}

.project-card:hover {
    box-shadow: 8px 8px 0 rgba(26, 26, 24, 0.08);
    transform: translate(-2px, -2px);
}

.project-card__image {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-right: 1px solid var(--line);
    background: #111;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.project-card__image:not(:has(img)) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.project-card__body {
    min-width: 0;
    padding: 1rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.project-card__title {
    margin: 0.65rem 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-card__desc {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.55;
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.project-card__desc a {
    color: var(--accent);
}

.project-card__desc img {
    display: block;
    max-width: 100%;
    margin-top: 0.75rem;
    border: 1px solid var(--line);
}

.project-card__meta,
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.tag {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.68rem;
}

.project-card__link {
    display: inline-block;
    margin-top: 0.9rem;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.78rem;
    text-decoration: none;
}

.projects-carousel {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.projects-carousel__btn {
    flex: 0 0 2rem;
    align-self: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--line);
    background: rgba(240, 240, 237, 0.7);
    color: var(--muted);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 1.15rem;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.projects-carousel__btn:hover:not(:disabled),
.projects-carousel__btn:focus-visible:not(:disabled) {
    border-color: var(--text);
    background: var(--panel);
    color: var(--accent);
    outline: none;
}

.projects-carousel__btn:disabled {
    cursor: default;
    opacity: 0.35;
}

.projects-carousel__viewport {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.projects-carousel__viewport::-webkit-scrollbar {
    display: none;
}

.projects-carousel__track {
    display: flex;
    gap: var(--home-carousel-gap);
}

.projects-carousel__track > .project-card--vertical {
    flex: 0 0 var(--home-card-width);
    min-width: 0;
}

.project-card--vertical {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    width: var(--home-card-width);
    max-width: var(--home-card-width);
    min-width: 0;
    overflow: hidden;
    contain: inline-size;
}

.project-card--vertical .project-card__image {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
}

.project-card--vertical .project-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 0.7rem 0.75rem 0.75rem;
}

.project-card--vertical .project-card__title {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0.45rem 0 0.3rem;
    overflow: hidden;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    max-height: calc(1.35em * 2);
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
}

.project-card--vertical .project-card__summary {
    color: var(--muted);
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    font-size: 0.78rem;
    line-height: 1.45;
    margin: 0;
    max-height: calc(1.45em * 3);
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
}

.project-card--vertical .project-card__tags-line {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-top: 0.45rem;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.62rem;
    line-height: 1.35;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-card--vertical .project-card__link {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-top: auto;
    padding-top: 0.5rem;
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-card--vertical .badge {
    align-self: flex-start;
    max-width: 100%;
    font-size: 0.62rem;
}

.project-detail {
    padding: 1.25rem;
}

.project-detail__grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1fr);
    gap: 1.25rem;
    margin-top: 1rem;
}

.project-detail__image {
    border: 1px solid var(--line);
}

.project-detail__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.project-detail__title {
    margin: 0.65rem 0 0.75rem;
    font-size: clamp(1.25rem, 2.2vw, 1.65rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.project-detail__meta .tag-list {
    margin-top: 0;
}

.project-detail__meta .project-card__link,
.project-detail__meta .empty {
    margin-top: 0.75rem;
}

.project-detail__content {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-button {
    min-height: 36px;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.75rem;
}

.filter-button.is-active,
.filter-button:hover,
.filter-button:focus-visible {
    border-color: var(--text);
    color: var(--text);
    outline: none;
}

.notes-list {
    border-top: 1px solid var(--line);
}

.note-row {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
}

.note-row__main {
    display: grid;
    gap: 0.3rem;
    min-width: 0;
}

.note-row__excerpt {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.note-row:hover .note-row__title {
    color: var(--accent);
}

.note-row__date,
.note-row__tag {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
}

.note-row__title {
    font-size: 1.1rem;
    font-weight: 600;
}

.note-article {
    max-width: 760px;
    padding: 1.25rem;
}

.note-article h1,
.note-article__title {
    margin: 0 0 0.5rem;
    font-size: clamp(1.45rem, 2.8vw, 2rem);
    letter-spacing: -0.03em;
    line-height: 1.15;
    font-weight: 600;
}

.note-content {
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.65;
}

.note-content > :first-child {
    margin-top: 0;
}

.note-content > :last-child {
    margin-bottom: 0;
}

.note-content p,
.note-content ul,
.note-content ol,
.note-content blockquote,
.note-content pre {
    margin-bottom: 1rem;
}

.note-content h2,
.note-content h3,
.note-content h4 {
    margin: 1.5rem 0 0.75rem;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.note-content h2 { font-size: 1.75rem; }
.note-content h3 { font-size: 1.35rem; }
.note-content h4 { font-size: 1.1rem; }

.note-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.note-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border: 1px solid var(--line);
}

.note-content blockquote {
    padding-left: 1rem;
    border-left: 3px solid var(--line);
    color: var(--muted);
}

.note-content ul,
.note-content ol {
    padding-left: 1.25rem;
}

.note-article pre {
    white-space: pre-wrap;
}

.note-content :not(pre) > code {
    padding: 0.1em 0.35em;
    border: 1px solid var(--line);
    background: rgba(26, 26, 24, 0.06);
    font-family: var(--mono);
    font-size: 0.9em;
    white-space: pre-wrap;
}

.note-content pre[class*="language-"] {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    background: #1A1A18;
    color: #F0F0ED;
    font-family: var(--mono);
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre;
}

.note-content pre[class*="language-"] code {
    display: block;
    font-family: inherit;
    font-size: inherit;
    background: transparent;
    padding: 0;
    border: 0;
    color: inherit;
    white-space: inherit;
}

.about-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
    gap: 2rem;
    padding: 1.25rem;
}

.info-blocks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    padding: 1.25rem;
}

.info-block {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 1rem;
}

.info-block__title {
    margin-bottom: 0.75rem;
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.info-block__text {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.55;
    white-space: pre-line;
}

.info-block__text a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.pay-page {
    max-width: 640px;
}

.pay-card {
    margin-top: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--line);
    background: var(--panel);
}

.pay-card__title {
    margin: 0.75rem 0 0.5rem;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.pay-card__lead {
    color: var(--muted);
    line-height: 1.55;
}

.pay-card__file {
    margin-top: 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.pay-card__price {
    margin: 1rem 0;
    font-family: var(--mono);
    font-size: 1.35rem;
    font-weight: 600;
}

.pay-form {
    margin-top: 0.5rem;
}

.pay-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0.55rem 1rem;
    border: 1px solid var(--text);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
}

.pay-button:hover,
.pay-button:focus-visible {
    background: var(--accent-dark);
    outline: none;
}

.pay-button:disabled {
    cursor: default;
    opacity: 0.6;
}

.pay-button--download {
    background: var(--panel);
    color: var(--accent);
}

.pay-button--download:hover,
.pay-button--download:focus-visible {
    color: var(--accent-dark);
    background: var(--panel);
}

.pay-note {
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.pay-status {
    margin-top: 0.75rem;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.82rem;
}

.pay-status--ok {
    color: var(--accent);
}

.pay-status--error {
    color: var(--danger);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.project-file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.project-file-actions .pay-button,
.project-file-actions .project-card__link {
    margin-top: 0;
}

.about-text {
    max-width: 58ch;
    color: var(--text);
    font-size: 1.05rem;
}

.contacts {
    border: 1px solid var(--line);
    padding: 1rem;
}

.contacts h2 {
    margin-bottom: 0.75rem;
    font-family: var(--mono);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.contacts a {
    display: block;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.85rem;
    text-decoration: none;
}

.footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
}

.skeleton {
    position: relative;
    min-height: 140px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #D5D5CD;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(240, 240, 237, 0.55), transparent);
    animation: skeleton 1.2s infinite;
}

@keyframes skeleton {
    to {
        transform: translateX(100%);
    }
}

.empty,
.error {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.85rem;
}

.error {
    color: var(--danger);
}

/* Pixel chase */
.pixel-chase {
    width: 184px;
    height: 38px;
    flex: 0 0 auto;
    overflow: hidden;
}

.pixel-chase svg {
    display: block;
    width: 184px;
    height: 38px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.rails {
    animation: rails-move 0.42s linear infinite;
}

@keyframes rails-move {
    from { transform: translateX(0); }
    to { transform: translateX(-12px); }
}

.train {
    animation: train-chug 0.5s steps(2, end) infinite;
}

@keyframes train-chug {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

.wheel {
    transform-box: fill-box;
    transform-origin: center;
    animation: wheel-spin 0.46s steps(4, end) infinite;
}

@keyframes wheel-spin {
    to { transform: rotate(360deg); }
}

.smoke {
    animation: smoke-rise 1.15s steps(4, end) infinite;
}

@keyframes smoke-rise {
    0% { opacity: 0.9; transform: translate(0, 0); }
    100% { opacity: 0; transform: translate(-3px, -9px); }
}

.dino {
    animation: dino-run 0.22s steps(2, end) infinite;
}

@keyframes dino-run {
    0%, 49% { transform: translateY(0); }
    50%, 100% { transform: translateY(-2px); }
}

.dino-leg-a {
    animation: leg-a 0.22s steps(1, end) infinite;
}

.dino-leg-b {
    opacity: 0;
    animation: leg-b 0.22s steps(1, end) infinite;
}

@keyframes leg-a {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes leg-b {
    0%, 49% { opacity: 0; }
    50%, 100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .dino-leg-a { opacity: 1; }
    .dino-leg-b { opacity: 0; }
}

@media (max-width: 1179px) {
    :root {
        --home-card-width: clamp(160px, calc((100vw - 8.5rem) / 5), 188px);
    }
}

@media (max-width: 900px) {
    .grid,
    .grid--projects {
        grid-template-columns: 1fr;
    }

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

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

@media (max-width: 760px) {
    :root {
        --home-card-width: min(72vw, 220px);
    }

    .page {
        padding: 1rem;
    }

    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .project-card:not(.project-card--list) {
        grid-template-columns: 1fr;
    }

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

    .project-card:not(.project-card--list) .project-card__image {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .project-card--list .project-card__top {
        grid-template-columns: 1fr;
        border-bottom: 1px solid var(--line);
    }

    .project-card--list .project-card__image {
        border-bottom: 0;
    }

    .note-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .nav {
        flex-wrap: wrap;
    }
}
