* {
    box-sizing: border-box;
}

html {
    background: var(--black);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--foreground);
    background: var(--black);
    font-family: "MesloLGS NF", "Meslo LG S", "MesloLGS", "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

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

::selection {
    color: var(--background);
    background: var(--cursor);
}

.terminal-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.terminal-shell {
    display: grid;
    min-height: calc(100vh - 71px);
    padding: 12px;
    place-items: stretch;
    background: var(--black);
}

.terminal-window {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    min-height: calc(100vh - 101px);
    border: 1px solid var(--purple);
    border-radius: 3px;
    background: rgba(27, 21, 25, .78);
    box-shadow: 0 0 0 1px rgba(104, 67, 174, .24), 0 18px 70px rgba(0, 0, 0, .46);
}

.terminal-chrome {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid #42333b;
}

.terminal-chrome span {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: var(--cursor);
}

.terminal-chrome span:nth-child(2) {
    background: var(--red);
}

.terminal-chrome span:nth-child(3) {
    background: var(--magenta);
}

.terminal-chrome code {
    margin-left: 10px;
    color: var(--foreground);
}

.terminal-body {
    min-height: 0;
    color: var(--foreground);
}

.terminal-body .home-name {
    width: max-content;
    max-width: 100%;
    margin: 0;
    color: var(--white);
    font-size: clamp(34px, 3.4vw, 48px);
    line-height: 1.04;
    letter-spacing: 0;
    white-space: nowrap;
}

.terminal-body p,
.terminal-body li {
    color: var(--foreground);
    font-size: 17px;
    line-height: 1.6;
}

.prompt {
    color: var(--cursor);
    font-weight: 800;
}

.tmux-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, .72fr);
    gap: 0;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.tmux-pane {
    min-width: 0;
    padding: 12px clamp(12px, 2.4vw, 26px) clamp(12px, 2.4vw, 26px);
    overflow: auto;
}

.tmux-pane + .tmux-pane {
    border-left: 0;
}

.tmux-layout::after {
    content: "";
    position: absolute;
    top: 12px;
    bottom: 0;
    left: calc(100% / 1.72);
    border-left: 1px solid var(--purple);
    pointer-events: none;
}

.tmux-pane-stack {
    display: grid;
    grid-template-rows: auto minmax(170px, 1fr) auto;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.tmux-subpane {
    position: relative;
    min-height: 0;
    padding: 0 clamp(12px, 2.2vw, 24px) clamp(12px, 2.2vw, 24px);
    overflow: auto;
}

.tmux-pane-stack > .tmux-subpane:first-child {
    padding-top: 12px;
}

.tmux-pane > :first-child,
.tmux-subpane > :first-child {
    margin-top: 0;
}

.terminal-body p:has(.prompt),
.terminal-body p:has(.starship-prompt) {
    margin: 10px 0 0;
}

.terminal-body p:has(.prompt):first-child,
.terminal-body p:has(.starship-prompt):first-child,
.tmux-subpane > p:has(.prompt):first-child {
    margin-top: 0;
}

.terminal-body p:has(.prompt) + h1,
.terminal-body p:has(.prompt) + p,
.terminal-body p:has(.prompt) + ul,
.terminal-body p:has(.prompt) + img,
.terminal-body p:has(.prompt) + pre,
.terminal-body p:has(.starship-prompt) + h1,
.terminal-body p:has(.starship-prompt) + p,
.terminal-body p:has(.starship-prompt) + ul,
.terminal-body p:has(.starship-prompt) + img,
.terminal-body p:has(.starship-prompt) + pre {
    margin-top: 0;
}

.research-tree {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--foreground);
    font: inherit;
    font-size: 15px;
    line-height: 1.45;
    overflow-x: auto;
    white-space: pre;
}

.research-tree a {
    color: var(--link);
    font-weight: 800;
}

.research-tree a:hover {
    color: var(--white);
}

.tree-dir {
    color: var(--magenta);
    font-weight: 800;
}

.tree-leaf {
    color: var(--foreground);
}

.tmux-subpane + .tmux-subpane {
    border-top: 0;
}

.tmux-subpane + .tmux-subpane::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    display: block;
    height: 1px;
    background: var(--purple);
}

.tmux-image-pane {
    display: grid;
    align-content: start;
    gap: 8px;
    overflow: hidden;
    padding-bottom: 8px;
}

.tmux-image-pane img {
    width: min(220px, 55%);
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
    border: 0;
    border-radius: 0;
    margin: 0;
}

.tmux-pane-stack > .tmux-subpane:last-child {
    padding-bottom: clamp(18px, 2.8vw, 32px);
}

.tmux-dna-pane {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
}

.tmux-dna-pane pre {
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #dea6f5;
    font: inherit;
    font-size: 12px;
    line-height: 1;
    overflow: hidden;
    white-space: pre;
}

.tmux-status {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 0;
    margin: 0 12px 12px;
    padding: 3px 8px;
    color: var(--white);
    background: var(--purple);
    font-size: 14px;
    line-height: 1;
    font-weight: 800;
    overflow: hidden;
    white-space: nowrap;
}

.tmux-session {
    color: inherit;
}

.tmux-spacer {
    flex: 1;
}

.terminal-link-list {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
}

.terminal-link-list a {
    display: grid;
    grid-template-columns: 11ch auto;
    gap: 10px;
    border: 0;
    padding: 0;
    color: var(--link);
    font-size: 16px;
    font-weight: 700;
}

.terminal-link-list span {
    color: var(--muted);
}

@media (max-width: 850px) {
    .tmux-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        overflow: visible;
    }

    .tmux-layout::after {
        display: none;
    }

    .terminal-shell {
        min-height: auto;
        padding: 8px;
    }

    .terminal-window {
        min-height: auto;
    }

    .terminal-chrome {
        padding: 8px 10px;
    }

    .terminal-body p,
    .terminal-body li {
        font-size: 14px;
        line-height: 1.35;
    }

    .terminal-body p,
    .terminal-body ul {
        margin-top: 8px;
        margin-bottom: 8px;
    }

    .terminal-body p:has(.prompt),
    .terminal-body p:has(.starship-prompt) {
        margin: 8px 0 0;
    }

    .terminal-body p:has(.prompt):first-child,
    .terminal-body p:has(.starship-prompt):first-child,
    .tmux-subpane > p:has(.prompt):first-child {
        margin-top: 0;
    }

    .terminal-body p:has(.prompt) + h1,
    .terminal-body p:has(.prompt) + p,
    .terminal-body p:has(.prompt) + ul,
    .terminal-body p:has(.prompt) + img,
    .terminal-body p:has(.prompt) + pre,
    .terminal-body p:has(.starship-prompt) + h1,
    .terminal-body p:has(.starship-prompt) + p,
    .terminal-body p:has(.starship-prompt) + ul,
    .terminal-body p:has(.starship-prompt) + img,
    .terminal-body p:has(.starship-prompt) + pre {
        margin-top: 0;
    }

    .research-tree {
        font-size: 12px;
        line-height: 1.35;
    }

    .tmux-pane {
        padding: 0 10px 10px;
        overflow: visible;
    }

    .tmux-pane-stack {
        grid-template-rows: auto auto auto;
        overflow: visible;
    }

    .tmux-subpane {
        padding: 0 10px 10px;
        overflow: visible;
    }

    .tmux-pane + .tmux-pane {
        border-left: 0;
        border-top: 0;
    }

    .tmux-pane + .tmux-pane::before {
        content: "";
        display: block;
        height: 1px;
        margin: 0 12px 0;
        background: var(--purple);
    }

    .tmux-image-pane {
        gap: 8px;
    }

    .tmux-image-pane img {
        width: min(128px, 42vw);
    }

    .tmux-dna-pane pre {
        height: 140px;
        font-size: 10px;
    }

    .terminal-body .home-name {
        font-size: clamp(24px, 7vw, 34px);
    }

    .tmux-status {
        gap: 8px;
        font-size: 12px;
    }
}
