.chatgpt-page {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 8% 10%, rgba(16, 163, 127, 0.12), transparent 34rem),
        var(--bg);
}

.chat-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    width: min(1280px, 94vw);
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    padding: 1rem 0 1.25rem;
    overflow: hidden;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.4rem 1.1rem 1rem 0;
    border-right: 1px solid var(--line);
}

.chat-sidebar h1 {
    margin-bottom: 0.55rem;
    color: var(--ink);
    font-size: 2.25rem;
}

.chat-sidebar > div > p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.6;
}

.new-chat-button {
    width: 100%;
}

.chat-starters {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-starters > span {
    margin-bottom: 0.15rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chat-starters button {
    padding: 0.72rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 750;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
}

.chat-starters button:hover,
.chat-starters button:focus-visible {
    border-color: rgba(16, 163, 127, 0.5);
    background: rgba(16, 163, 127, 0.08);
}

.chat-model-note {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: auto 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
}

.chat-model-note span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10a37f;
    box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.14);
}

.chat-panel {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: clamp(1.25rem, 4vw, 3.5rem) clamp(1rem, 6vw, 5rem) 1rem;
    scroll-behavior: smooth;
}

.chat-message {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 0.8rem;
    max-width: 780px;
    margin: 0 auto 1.4rem;
}

.chat-message-user {
    grid-template-columns: minmax(0, 1fr) 34px;
}

.chat-message-user > div:not(.chat-avatar) {
    justify-self: end;
    max-width: min(620px, 88%);
    padding: 0.75rem 0.95rem;
    border-radius: 16px 5px 16px 16px;
    background: var(--blue);
    color: #fff;
}

.chat-message-user .chat-avatar {
    grid-column: 2;
    grid-row: 1;
    background: #315a8c;
}

.chat-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #10a37f;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 950;
}

.chat-message-label {
    display: block;
    margin: 0 0 0.35rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.chat-message-user .chat-message-label {
    color: rgba(255, 255, 255, 0.72);
}

.chat-message-content,
.chat-message-body {
    min-width: 0;
}

.chat-message-body {
    color: var(--ink);
    line-height: 1.68;
}

.chat-message-body > :first-child {
    margin-top: 0;
}

.chat-message-body > :last-child {
    margin-bottom: 0;
}

.chat-message-body p {
    margin: 0 0 0.9rem;
}

.chat-message-user .chat-message-body p {
    white-space: pre-wrap;
}

.chat-message-user .chat-message-body {
    color: #fff;
}

.chat-message-body h2,
.chat-message-body h3,
.chat-message-body h4 {
    margin: 1.25rem 0 0.55rem;
    color: var(--ink);
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.chat-message-body h2 {
    font-size: 1.25rem;
}

.chat-message-body h3 {
    font-size: 1.08rem;
}

.chat-message-body h4 {
    font-size: 1rem;
}

.chat-message-body ul,
.chat-message-body ol {
    margin: 0.35rem 0 1rem;
    padding-left: 1.45rem;
}

.chat-message-body li {
    padding-left: 0.2rem;
}

.chat-message-body li + li {
    margin-top: 0.45rem;
}

.chat-message-body strong {
    color: var(--ink);
    font-weight: 900;
}

.chat-message-body code {
    padding: 0.12rem 0.32rem;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.08);
    color: var(--ink);
    font: 0.9em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.chat-message-body pre {
    max-width: 100%;
    margin: 0.6rem 0 1rem;
    padding: 0.9rem 1rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.06);
}

.chat-message-body pre code {
    padding: 0;
    background: transparent;
    white-space: pre;
}

.chat-message-body blockquote {
    margin: 0.55rem 0 1rem;
    padding: 0.15rem 0 0.15rem 0.9rem;
    border-left: 3px solid rgba(16, 163, 127, 0.55);
    color: var(--muted);
}

.chat-math-display {
    max-width: 100%;
    margin: 0.65rem 0 1rem;
    padding: 0.55rem 0.7rem;
    overflow-x: auto;
    border-radius: 9px;
    background: rgba(16, 163, 127, 0.055);
    text-align: center;
}

.chat-math-display .katex-display {
    margin: 0;
}

.chat-math-inline {
    display: inline-block;
    max-width: 100%;
    vertical-align: -0.08em;
}

.chat-message.is-thinking .chat-message-body {
    color: var(--muted);
}

.chat-message.is-error > div:last-child {
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(220, 38, 38, 0.25);
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.07);
}

.chat-composer {
    position: relative;
    width: min(800px, calc(100% - 2rem));
    margin: 0 auto;
    padding-bottom: 0.2rem;
}

.chat-composer textarea {
    display: block;
    width: 100%;
    max-height: 180px;
    min-height: 58px;
    resize: none;
    padding: 1rem 5.4rem 1rem 1rem;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    line-height: 1.45;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
}

.chat-composer:has(.chat-attachment:not([hidden])) textarea {
    padding-top: 3.9rem;
}

.chat-attachment {
    position: absolute;
    z-index: 2;
    top: 8px;
    left: 9px;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    max-width: calc(100% - 7rem);
    padding: 0.38rem 0.5rem;
    border: 1px solid rgba(16, 163, 127, 0.28);
    border-radius: 9px;
    background: color-mix(in srgb, var(--surface) 92%, #10a37f);
    color: var(--ink);
    font-size: 0.75rem;
}

.chat-attachment[hidden] {
    display: none;
}

.chat-attachment > span {
    padding: 0.2rem 0.3rem;
    border-radius: 5px;
    background: #10a37f;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 950;
}

.chat-attachment strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment button {
    position: static;
    min-height: auto;
    margin-left: auto;
    padding: 0.15rem 0.25rem;
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
}

.chat-text-file {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.45rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    color: inherit;
    font-size: 0.78rem;
    font-weight: 800;
}

.chat-sources {
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--line);
}

.chat-sources strong {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.chat-sources a {
    display: inline-block;
    margin: 0.2rem 0.45rem 0.2rem 0;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--blue);
    font-size: 0.76rem;
    font-weight: 800;
    text-decoration: none;
}

.chat-composer textarea:focus {
    outline: 3px solid rgba(16, 163, 127, 0.18);
    border-color: rgba(16, 163, 127, 0.55);
}

.chat-composer button {
    position: absolute;
    top: 8px;
    right: 8px;
    min-height: 42px;
    padding: 0 0.9rem;
    border: 0;
    border-radius: 11px;
    background: #10a37f;
    color: #fff;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.chat-composer button:disabled {
    opacity: 0.5;
    cursor: wait;
}

.chat-composer > p {
    margin: 0.45rem 0 0;
    color: var(--muted);
    font-size: 0.72rem;
    text-align: center;
}

.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;
}

@media (max-width: 820px) {
    .chatgpt-page {
        overflow: hidden;
    }

    .chat-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        height: 100%;
        min-height: 0;
        padding-top: 0;
    }

    .chat-sidebar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 1rem 0;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .chat-sidebar h1 {
        font-size: 1.65rem;
    }

    .chat-sidebar > div > p:not(.eyebrow),
    .chat-starters,
    .chat-model-note {
        display: none;
    }

    .new-chat-button {
        width: auto;
    }

    .chat-panel {
        min-height: 0;
    }

    .chat-messages {
        min-height: 0;
        padding-inline: 0;
    }
}
