:root {
    --ton-bg: #131213;
    --ton-line: rgba(255, 255, 255, 0.10);
    --ton-text: #ffffff;
    --ton-muted: rgba(255, 255, 255, 0.58);
    --ton-dim: rgba(255, 255, 255, 0.34);
    --ton-blue: #62b2f3;
    --ton-panel: rgba(255, 255, 255, 0.045);
    --ton-panel-strong: rgba(255, 255, 255, 0.07);
    --ton-cube-width: 100vh;
    --ton-cube-right: calc(50vw - (var(--ton-cube-width) / 2));
    --ton-cube-bottom: -7%;
    --ton-cube-opacity: 0.026;
    --ton-cube-rotate: 360deg;
}

html {
    scroll-behavior: smooth;
}

body.ton-body {
    min-height: 100vh;
    color: var(--ton-text);
    overflow-x: hidden;
    background: var(--ton-bg);
}

.ton-body a {
    cursor: url(../images/cursors/link.cur), pointer;
}

.ton-loader {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: #131213;
    animation: ton-loader-shell 2.1s ease forwards;
    transition: opacity 0.7s ease, visibility 0.7s ease;
}

body.cube-loading .ton-loader,
body.cube-loading .ton-loader img {
    animation-play-state: paused;
}

body.cube-loading .ton-loader img,
body.cube-loading .ton-bg-cube {
    visibility: hidden;
}

body.skip-loader .ton-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    animation: none;
}

body.page-transition-out .ton-page {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.992);
    transition: opacity 0.08s ease, transform 0.08s cubic-bezier(0.77, 0, 0.2, 0.85);
}

body.route-content-pending .ton-page {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.996);
}

body.route-content-pending .ton-bg-cube {
    visibility: hidden;
}

body.route-cube-transitioning .ton-bg-cube {
    visibility: hidden;
}

.ton-route-cube {
    position: fixed;
    z-index: 0;
    height: auto;
    aspect-ratio: 2076 / 2400;
    max-width: none;
    pointer-events: none;
    transform-origin: center;
    will-change: left, top, width, opacity, transform;
}

.ton-loader img {
    position: fixed;
    right: calc(50vw - 85px);
    bottom: calc(50vh - 85px);
    width: 170px;
    height: auto;
    aspect-ratio: 2076 / 2400;
    max-width: none;
    animation: ton-loader-cube 1.7s cubic-bezier(0.77, 0, 0.2, 0.85) forwards;
    will-change: width, right, bottom, opacity, transform;
}

.ton-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ton-bg-cube {
    position: fixed;
    right: var(--ton-cube-right);
    bottom: var(--ton-cube-bottom);
    z-index: 0;
    width: var(--ton-cube-width);
    height: auto;
    aspect-ratio: 2076 / 2400;
    max-width: none;
    opacity: var(--ton-cube-opacity);
    transform: rotate(var(--ton-cube-rotate));
    transform-origin: center;
    will-change: right, bottom, width, opacity, transform;
}

.ton-page {
    position: relative;
    z-index: 1;
    width: min(1040px, calc(100vw - 40px));
    margin: 0 auto;
    padding: 86px 0 64px;
    transition: opacity 0.14s ease, transform 0.14s cubic-bezier(0.77, 0, 0.2, 0.85);
}

.ton-shell {
    display: grid;
    grid-template-columns: minmax(0, 760px) 180px;
    gap: 64px;
    align-items: start;
}

.ton-content {
    min-width: 0;
}

.ton-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}

.ton-brand,
.ton-route-mark,
.ton-nav a,
.ton-scope span,
.ton-title-row a,
.ton-footer a {
    font-family: 'Montserrat', sans-serif;
}

.ton-brand {
    color: var(--ton-text);
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    transition: color 0.22s ease;
}

.ton-brand:hover,
.ton-nav a:hover,
.ton-title-row a:hover,
.ton-footer a:hover,
.ton-project-title a:hover {
    color: var(--ton-text);
}

.ton-route-mark {
    color: var(--ton-dim);
    font-size: 14px;
    line-height: 1.2;
}

.ton-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
}

.ton-nav a,
.ton-footer a {
    position: relative;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.84);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.1;
    padding: 10px;
    transition: background 0.22s ease, color 0.22s ease;
}

.ton-nav a:hover,
.ton-footer a:hover {
    background: rgba(255, 255, 255, 0.075);
}

.ton-intro {
    margin-top: 72px;
}

.ton-intro h1 {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 96px;
    font-weight: 600;
    line-height: 0.95;
    letter-spacing: 0;
}

.ton-intro p {
    width: min(640px, 100%);
    margin-top: 18px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 17px;
    line-height: 1.65;
}

.ton-workflow-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    width: min(640px, 100%);
    margin-top: 30px;
    border-top: 1px solid var(--ton-line);
    border-bottom: 1px solid var(--ton-line);
}

.ton-workflow-nav a,
.ton-side-nav a,
.ton-side-nav span {
    font-family: 'Montserrat', sans-serif;
}

.ton-workflow-nav a {
    min-width: 0;
    padding: 13px 10px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 13px;
    line-height: 1.1;
    text-align: center;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease;
}

.ton-workflow-nav a + a {
    border-left: 1px solid var(--ton-line);
}

.ton-workflow-nav a:hover,
.ton-side-nav a:hover {
    color: #fff;
    background: var(--ton-panel);
}

.ton-scope {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 26px;
}

.ton-scope span {
    color: var(--ton-muted);
    font-size: 14px;
    line-height: 1.2;
}

.ton-scope span::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    margin: 0 8px 2px 0;
    border-radius: 50%;
    background: var(--ton-blue);
    opacity: 0.72;
}

.ton-projects {
    margin-top: 76px;
}

.ton-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    min-height: 48px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--ton-line);
}

.ton-title-row p {
    width: min(560px, 100%);
    margin-top: 10px;
    color: var(--ton-muted);
    font-size: 15px;
    line-height: 1.58;
}

.ton-title-row h2,
.ton-category h3 {
    margin: 0;
    font-family: 'Raleway', sans-serif;
    font-weight: 100;
    line-height: 1.05;
}

.ton-title-row h2 {
    font-size: 42px;
}

.ton-title-row a {
    flex: 0 0 auto;
    margin-bottom: 4px;
    color: var(--ton-blue);
    text-decoration: none;
    font-size: 14px;
}

.ton-category {
    margin-top: 36px;
}

.ton-category h3 {
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 28px;
}

.ton-project-list {
    border-bottom: 1px solid rgba(255, 255, 255, 0.075);
}

.ton-project-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 18px;
    position: relative;
    padding: 20px 12px 20px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.075);
    opacity: 0;
    transform: translateY(18px);
    transition: background 0.18s ease, opacity 0.56s ease, transform 0.56s cubic-bezier(0.77, 0, 0.2, 0.85);
}

.ton-project-card::before {
    content: "";
    position: absolute;
    top: 18px;
    bottom: 18px;
    left: -14px;
    width: 2px;
    background: var(--ton-blue);
    opacity: 0;
    transform: scaleY(0.72);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ton-project-card:hover {
    background: linear-gradient(90deg, var(--ton-panel), rgba(255, 255, 255, 0));
}

.ton-project-card:hover::before {
    opacity: 0.7;
    transform: scaleY(1);
}

.ton-project-card.is-visible,
.ton-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.ton-project-card img,
.ton-project-avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
}

.ton-project-card img {
    object-fit: cover;
    transition: transform 0.18s ease;
}

.ton-project-card:hover img {
    transform: scale(1.035);
}

.ton-project-avatar {
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--ton-blue);
    background: rgba(98, 178, 243, 0.08);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
}

.ton-project-info {
    min-width: 0;
}

.ton-project-title {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.ton-project-title a,
.ton-project-title strong {
    color: var(--ton-blue);
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.ton-project-title a::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 8px;
    border-top: 1px solid currentColor;
    border-right: 1px solid currentColor;
    opacity: 0.52;
    transform: translateY(-3px) rotate(45deg);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ton-project-title a:hover::after {
    opacity: 0.9;
    transform: translate(2px, -5px) rotate(45deg);
}

.ton-project-title strong {
    display: block;
}

.ton-project-title span {
    flex: 0 0 auto;
    margin-top: 2px;
    padding: 5px 7px;
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.42);
    background: rgba(255, 255, 255, 0.08);
    font-size: 11px;
    line-height: 1;
    text-transform: uppercase;
}

.ton-project-card p {
    margin-top: 7px;
    color: rgba(255, 255, 255, 0.42);
    font-size: 15px;
    line-height: 1.55;
}

.ton-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 52px;
    padding-top: 18px;
    border-top: 1px solid var(--ton-line);
}

.ton-footer p {
    margin: 0;
    color: var(--ton-muted);
    font-size: 15px;
    line-height: 1.55;
}

.ton-footer a {
    flex: 0 0 auto;
    color: var(--ton-text);
}

.ton-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.62s ease, transform 0.62s cubic-bezier(0.77, 0, 0.2, 0.85);
}

.ton-side-nav {
    position: sticky;
    top: 32px;
    display: grid;
    gap: 2px;
    margin-top: 146px;
    padding-top: 10px;
    border-top: 1px solid var(--ton-line);
}

.ton-side-nav span {
    display: block;
    margin-bottom: 8px;
    color: var(--ton-dim);
    font-size: 11px;
    line-height: 1.1;
    text-transform: uppercase;
}

.ton-side-nav a {
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.66);
    font-size: 13px;
    line-height: 1.2;
    padding: 8px 9px;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease;
}

@keyframes ton-loader-cube {
    0% {
        opacity: 0;
        transform: rotate(0deg) scale(0.72);
    }
    35% {
        opacity: 1;
        transform: rotate(160deg) scale(1);
    }
    100% {
        right: var(--ton-cube-right);
        bottom: var(--ton-cube-bottom);
        width: var(--ton-cube-width);
        opacity: var(--ton-cube-opacity);
        transform: rotate(var(--ton-cube-rotate)) scale(1);
    }
}

@keyframes ton-loader-shell {
    0%, 78% {
        opacity: 1;
        visibility: visible;
    }
    100% {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

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

    .ton-loader,
    .ton-loader img,
    .ton-route-cube,
    .ton-reveal,
    .ton-project-card,
    .ton-project-card::before,
    .ton-nav a,
    .ton-footer a,
    .ton-workflow-nav a,
    .ton-side-nav a {
        animation: none;
        transition: none;
    }

    .ton-reveal,
    .ton-project-card {
        opacity: 1;
        transform: none;
    }
}

@media screen and (max-width: 620px) {
    :root {
        --ton-cube-width: 86vh;
        --ton-cube-right: -34vh;
        --ton-cube-opacity: 0.03;
    }

    .ton-page {
        width: calc(100vw - 24px);
        padding: 32px 0 48px;
    }

    .ton-shell {
        display: block;
    }

    .ton-side-nav {
        display: none;
    }

    .ton-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    .ton-nav {
        width: 100%;
        justify-content: flex-start;
        gap: 4px;
        margin: 8px 0 0;
    }

    .ton-nav a {
        padding: 9px 8px;
        font-size: 13px;
    }

    .ton-intro {
        margin-top: 48px;
    }

    .ton-intro h1 {
        font-size: 74px;
    }

    .ton-intro p {
        margin-top: 14px;
        font-size: 16px;
        line-height: 1.58;
    }

    .ton-scope {
        gap: 9px 14px;
        margin-top: 22px;
    }

    .ton-workflow-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 24px;
    }

    .ton-workflow-nav a {
        padding: 12px 8px;
    }

    .ton-workflow-nav a:nth-child(3) {
        border-left: 0;
        border-top: 1px solid var(--ton-line);
    }

    .ton-workflow-nav a:nth-child(4) {
        border-top: 1px solid var(--ton-line);
    }

    .ton-projects {
        margin-top: 58px;
    }

    .ton-title-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .ton-title-row h2 {
        font-size: 36px;
    }

    .ton-category {
        margin-top: 30px;
    }

    .ton-category h3 {
        font-size: 25px;
    }

    .ton-project-card {
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 14px;
        padding: 18px 0;
    }

    .ton-project-card::before {
        display: none;
    }

    .ton-project-card img,
    .ton-project-avatar {
        width: 48px;
        height: 48px;
    }

    .ton-project-title {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 7px;
    }

    .ton-project-title a,
    .ton-project-title strong {
        font-size: 21px;
    }

    .ton-project-card p {
        font-size: 14px;
        line-height: 1.5;
    }

    .ton-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}
