* {
    box-sizing: border-box;
}

:root {
    --chat-panel-width: clamp(390px, 28vw, 560px);
    --chat-ink: #111111;
    --chat-muted: #6D6861;
    --chat-border: rgba(53, 47, 39, 0.14);
    --chat-hairline: rgba(53, 47, 39, 0.09);
    --chat-panel-surface: #FFFDF8;
    --chat-shadow: 0 18px 56px rgba(61, 47, 33, 0.10);
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background-color: #FCF8F2;
    color: #111111;
}

body.chat-resizing {
    cursor: ew-resize;
    user-select: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.navbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 2px;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 90;
    padding: 20px;
}

.navbar ul {
    list-style-type: none;
    font-family: "Montserrat", sans-serif;
    font-size: 1em;
    font-weight: 500;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 20px;
    border-radius: 999px;
    background: rgba(252, 248, 242, 0.88);
    padding: 0.35rem 0.5rem;
    backdrop-filter: blur(8px);
}

body.chat-open:not(.chat-mobile-hidden) .navbar ul {
    background: transparent;
    backdrop-filter: none;
}

.navbar li {
    display: inline;
}

.navbar a {
    text-decoration: none;
    color: black;
}

.page-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 100vh;
}

body.chat-open .page-shell {
    grid-template-columns: minmax(0, 1fr) var(--chat-panel-width);
}

.portfolio-area {
    min-width: 0;
}

.level-one {
    display: flex;
    min-height: 100vh;
    justify-content: center;
    align-items: flex-start;
    gap: 9rem;
    flex-wrap: wrap;
    padding: 3rem 4rem 4rem;
}

body.chat-open .level-one {
    gap: 2rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.profile-pic {
    flex: 0 1 525px;
    margin-top: 0.25rem;
}

body.chat-open .profile-pic {
    flex-basis: 430px;
}

.profile-pic img {
    width: 525px;
    border-radius: 2%;
}

body.chat-open .profile-pic img {
    width: 430px;
}

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

.intro-container {
    display: flex;
    flex: 1 1 560px;
    flex-direction: column;
    max-width: 700px;
    min-width: 320px;
    align-items: center;
    margin-top: 10%;
    color: #2C2C2C;
}

body.chat-open .intro-container {
    flex-basis: 480px;
    max-width: 560px;
    margin-top: 12%;
}

.intro {
    text-transform: uppercase;
    color: black;
    font-family: "Montserrat", sans-serif;
    letter-spacing: 0;
    font-size: 2.5em;
    font-weight: 700;
    text-align: center;
}

.bio {
    color: black;
    font-family: "Roboto", sans-serif;
    letter-spacing: 0;
    font-size: 0.7em;
    line-height: 1.375;
    font-weight: 500;
}

.bio p {
    font-weight: 300;
    letter-spacing: 0;
    font-size: 1.5em;
    text-align: justify;
    margin-top: 5%;
    color: black;
}

.images {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.images a {
    height: 35px;
    flex-shrink: 0;
    width: 35px;
}

.images img {
    width: 25px;
    height: 25px;
}

.chat-composer {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.6rem;
    border: 1px solid var(--chat-border);
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 44px rgba(61, 47, 33, 0.08);
    padding: 0.55rem 0.58rem 0.55rem 1.05rem;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.chat-composer:focus-within {
    border-color: rgba(17, 17, 17, 0.34);
    background: #FFFFFF;
    box-shadow: 0 18px 50px rgba(61, 47, 33, 0.12);
}

.landing-chat-composer {
    max-width: 585px;
    margin-top: 2rem;
}

body.chat-open .landing-chat-composer {
    display: none;
}

.chat-reopen-button {
    display: none;
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    z-index: 35;
    border: 1px solid var(--chat-border);
    border-radius: 999px;
    background: #FFFFFF;
    box-shadow: var(--chat-shadow);
    color: var(--chat-ink);
    cursor: pointer;
    font-family: "Montserrat", sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.8rem 1.1rem;
}

body.chat-has-history:not(.chat-open) .chat-reopen-button {
    display: inline-flex;
}

.chat-composer input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--chat-ink);
    font-family: "Roboto", sans-serif;
    font-size: 1rem;
}

.chat-composer input::placeholder {
    color: #8E8982;
}

.chat-send-button,
.chat-close-button {
    border: 0;
    cursor: pointer;
    font-family: "Montserrat", sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
}

.chat-send-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.35rem;
    height: 2.35rem;
    min-width: 0;
    border-radius: 50%;
    background: #000000;
    color: #FFFFFF;
    padding: 0;
    transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.chat-send-button span {
    font-family: "Roboto", sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
    transform: translateY(-1px);
}

.chat-send-button:hover:not(:disabled),
.chat-send-button:focus-visible:not(:disabled) {
    background: #1E1E1E;
    transform: translateY(-1px);
}

.chat-send-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.chat-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    flex-direction: column;
    width: var(--chat-panel-width);
    min-width: var(--chat-panel-width);
    height: 100vh;
    margin: 0;
    border: 0;
    border-left: 1px solid var(--chat-border);
    border-radius: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 253, 248, 0.98) 44%),
        var(--chat-panel-surface);
    box-shadow: -16px 0 56px rgba(61, 47, 33, 0.10);
    overflow: hidden;
}

body.chat-open .chat-panel {
    display: flex;
}

.chat-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    width: 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: ew-resize;
    padding: 0;
}

.chat-resize-handle::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 5px;
    width: 3px;
    height: 64px;
    border-radius: 999px;
    background: rgba(54, 45, 35, 0.2);
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 160ms ease, background 160ms ease;
}

.chat-resize-handle:hover::before,
.chat-resize-handle:focus-visible::before,
body.chat-resizing .chat-resize-handle::before {
    background: rgba(54, 45, 35, 0.42);
    opacity: 1;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4.5rem clamp(1.15rem, 3vw, 1.7rem) 0.35rem;
    background: transparent;
}

.chat-experimental-notice {
    margin: 0.45rem 0 0;
    color: #A89E94;
    font-size: 0.68rem;
    text-align: center;
}

body.chat-open .chat-experimental-notice {
    display: none;
}

.chat-close-button {
    border-radius: 999px;
    background: transparent;
    color: var(--chat-ink);
    padding: 0.45rem 0.7rem;
}

.chat-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    background: transparent;
    color: rgba(17, 17, 17, 0.56);
    font-size: 1.35rem;
    font-weight: 400;
    line-height: 1;
    padding: 0;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.chat-close-button:hover,
.chat-close-button:focus-visible {
    background: rgba(233, 225, 214, 0.55);
    color: var(--chat-ink);
    transform: translateY(-1px);
}

.chat-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 1.15rem;
    overflow-y: auto;
    padding: 1rem clamp(1.2rem, 3vw, 1.8rem) 1.1rem;
    scrollbar-color: rgba(54, 45, 35, 0.28) transparent;
    scrollbar-width: thin;
}

.chat-message {
    display: flex;
    width: 100%;
    max-width: none;
    padding: 0.12rem 0;
    border: 0;
    border-radius: 0;
    font-family: "Roboto", sans-serif;
    font-size: 0.96rem;
    line-height: 1.58;
    overflow-wrap: anywhere;
    box-shadow: none;
}

.chat-message:first-child {
    padding-top: 0.25rem;
}

.chat-message.user {
    justify-content: flex-end;
    align-self: stretch;
    background: transparent;
    color: var(--chat-ink);
    box-shadow: none;
}

.chat-message.assistant {
    justify-content: flex-start;
    align-self: stretch;
    background: transparent;
    color: var(--chat-ink);
    box-shadow: none;
}

.chat-message-content {
    display: grid;
    gap: 0.62rem;
    min-width: 0;
    max-width: min(63ch, 100%);
}

.chat-message.user .chat-message-content {
    color: #25221F;
    font-weight: 500;
    max-width: min(38ch, 82%);
    text-align: right;
}

.chat-message.assistant .chat-message-content {
    text-align: left;
}

.chat-thinking-label {
    color: rgba(54, 45, 35, 0.68);
    font-size: 0.92rem;
    font-weight: 600;
}

.chat-message-content h3,
.chat-message-content p,
.chat-message-content ul,
.chat-message-content ol {
    margin: 0;
}

.chat-message-content h3 {
    font-family: "Montserrat", sans-serif;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.35;
}

.chat-message-content ul,
.chat-message-content ol {
    display: grid;
    gap: 0.3rem;
    padding-left: 1.05rem;
}

.chat-message-content li {
    padding-left: 0.1rem;
}

.chat-message-content strong {
    font-weight: 700;
}

.chat-message-content code {
    border: 1px solid rgba(54, 45, 35, 0.12);
    border-radius: 5px;
    background: rgba(233, 225, 214, 0.46);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.88em;
    padding: 0.05rem 0.28rem;
}

.chat-message-content a {
    color: var(--chat-ink);
    font-weight: 600;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

.chat-message.is-streaming::after {
    content: "";
    display: block;
    flex: 0 0 auto;
    width: 0.38rem;
    height: 0.95rem;
    margin: 0.35rem 0 0 0.15rem;
    vertical-align: -0.18rem;
    background: var(--chat-ink);
    animation: chat-cursor 0.9s steps(2, start) infinite;
}

.panel-chat-composer {
    flex-shrink: 0;
    width: auto;
    margin: 0 clamp(1rem, 3vw, 1.5rem) 1.05rem;
    box-shadow: 0 14px 44px rgba(61, 47, 33, 0.10);
}

@keyframes chat-cursor {
    50% {
        opacity: 0;
    }
}

@media screen and (max-width: 1400px) {
    .level-one {
        gap: 5rem;
        padding-left: 3rem;
        padding-right: 3rem;
    }

    .intro-container {
        max-width: 620px;
    }
}

@media screen and (max-width: 1099px) {
    .navbar {
        position: absolute;
    }

    body.chat-open .page-shell {
        display: block;
    }

    body.chat-open:not(.chat-mobile-hidden) .navbar,
    body.chat-open:not(.chat-mobile-hidden) .portfolio-area {
        display: none;
    }

    body.chat-open.chat-mobile-hidden .landing-chat-composer {
        display: flex;
    }

    body.chat-open.chat-mobile-hidden .chat-panel {
        display: none;
    }

    .chat-panel {
        inset: 0;
        z-index: 50;
        width: 100%;
        min-width: 0;
        height: auto;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .chat-resize-handle {
        display: none;
    }

    .chat-panel-header {
        padding-top: 1rem;
    }

    .level-one {
        min-height: 100vh;
        gap: 2rem;
        padding: 4.5rem 1.25rem 2rem;
    }

    .profile-pic,
    body.chat-open .profile-pic {
        flex-basis: min(525px, 100%);
    }

    .profile-pic img,
    body.chat-open .profile-pic img {
        width: min(525px, 100%);
        margin: 0 auto;
    }

    .intro-container,
    body.chat-open .intro-container {
        max-width: 680px;
        min-width: 0;
        margin-top: 0;
    }

    .intro {
        font-size: 2rem;
    }

    .bio p {
        text-align: left;
    }
}

@media screen and (max-width: 600px) {
    .navbar {
        left: 0;
        justify-content: center;
        padding: 1rem 0.75rem;
    }

    .navbar ul {
        gap: 14px;
        font-size: 0.92em;
    }

    .level-one {
        padding-top: 4rem;
    }

    .intro {
        font-size: 1.65rem;
    }

    .bio p {
        font-size: 1.35em;
    }

    .chat-composer {
        padding-left: 1rem;
    }

    .chat-send-button {
        width: 2.25rem;
        height: 2.25rem;
    }

    .chat-reopen-button {
        right: 1rem;
        bottom: 1rem;
    }
}
