:root {
    --bg: #f3f0e9;
    --txt: #1f1c1a;

    --txt4: #1f1c1a60;
    --txt3: #1f1c1a30;
    --txt1: #1f1c1a10;

    --accent: #ff7b00;
    --accent1: #f1750010;
}

@media (prefers-color-scheme: dark) {

    :root,
    [data-theme="dark"] {
        --bg: #1f1c1a;
        --txt: #f3f0e9;

        --txt4: #f3f0e960;
        --txt3: #f3f0e930;
        --txt1: #f3f0e910;

        --accent: #ff8d21;
        --accent1: #ff8d2110;
    }
}

* {
    outline: none;
    box-sizing: border-box;
    word-break: keep-all;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-size: .95rem;
    line-height: 1.3 !important;
    font-weight: 400;
    letter-spacing: 0;
    margin: 0;
    padding: 0;
    font-family: inherit;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-tap-highlight-color: transparent;
    font-family: "Geist Mono", "Inter", "Apple SD Gothic Neo", monospace;
}

*::-webkit-scrollbar {
    display: none;
}

*:focus {
    outline: none;
}

textarea {
    background: none;
    border: none;
    outline: none;
    padding: 0;
    margin: 0;

    color: inherit;
    font: inherit;
    text-align: inherit;

    resize: none;
    box-sizing: border-box;
    width: 100%;

    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    -webkit-tap-highlight-color: transparent;
    box-shadow: none;
}

textarea:focus {
    outline: none;
    box-shadow: none;
}

button {
    appearance: none;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--txt);
}

.main {
    height: var(--viewport-height, 100%);
    padding: 2rem 1rem 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.article {
    display: flex;
    align-items: baseline;
    width: 100%;
    min-height: 100%;
    max-width: 50rem;
}

.logo-text {
    flex-shrink: 0;
    position: sticky;
    top: 1rem;
    z-index: 2;
    background: var(--bg);
}

.composer {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.model {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-top: 1rem;
    background: linear-gradient(to bottom, var(--bg), transparent);
    backdrop-filter: blur(.5rem);
}

.command-token {
    color: var(--accent);
}

.command-token-ignored {
    color: var(--txt4);
    text-decoration: line-through;
}

.transcript {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.transcript:empty {
    display: none;
}

.turn {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
}

.turn.user {
    background: var(--txt1);
}

.turn.command {
    background: var(--accent1);
}

.turn-prefix {
    color: var(--txt4);
    white-space: pre;
}

.turn-prefix {
    visibility: hidden;
}

.turn.user .turn-prefix {
    visibility: visible;
}

.turn.command .turn-prefix {
    color: var(--accent);
    visibility: visible;
}

.turn-body,
.status-body,
.answer,
.reasoning-body {
    min-width: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.answer.markdown {
    white-space: normal;
}

.spinner {
    display: inline-block;
    width: 1rem;
    text-align: center;
    color: var(--accent);
}

.spinner.is-complete {
    width: auto;
}

.reasoning {
    display: contents;
}

.reasoning-body[hidden] {
    display: none;
}

.reasoning-body {
    color: var(--txt4);
}

.turn.assistant .turn-body {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.status-text[data-reasoning-complete="true"] {
    color: var(--txt);
}

.reasoning-arrow {
    margin-left: .5rem;
}

.char {
    display: inline-block;
    white-space: pre;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6,
.markdown strong,
.markdown th {
    font-weight: 700;
}

.markdown em {
    font-style: italic;
}

.markdown s {
    text-decoration: line-through;
}

.markdown a {
    color: inherit;
    text-decoration: underline;
}

.markdown ul,
.markdown ol {
    list-style-position: inside;
    padding-left: 0;
}

.markdown blockquote {
    padding-left: 2ch;
}

.markdown code {
    font: inherit;
}

.markdown pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.code-block {
    border: solid .05rem var(--txt3);
}

.code-header {
    display: flex;
    justify-content: space-between;
    border-bottom: solid .05rem var(--txt3);
}

.code-copy {
    color: var(--txt4);
}

.code-copy:hover {
    color: var(--txt);
}

.code-block pre {
    overflow-x: auto;
    white-space: pre;
}

.token-comment {
    color: var(--txt4);
}

.token-keyword {
    color: var(--accent);
}

.token-string {
    color: var(--txt);
    font-weight: 700;
}

.token-number {
    color: var(--txt);
    text-decoration: underline;
}

.markdown table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border: solid .05rem var(--txt3);
}

.markdown th,
.markdown td {
    border: solid .05rem var(--txt3);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.markdown>*+* {
    margin-top: .5rem;
}

@keyframes blurIn {
    from {
        filter: blur(12px);
        opacity: 0;
        transform: scale(1.1);
    }

    to {
        filter: blur(0);
        opacity: 1;
        transform: scale(1);
    }
}

.input {
    display: flex;
    align-items: flex-start;
    position: sticky;
    bottom: 0;
    z-index: 1;
    padding-bottom: 1rem;
    background: linear-gradient(to bottom, transparent 0%, var(--bg) 75%);
    backdrop-filter: blur(.5rem);
}

.prefix {
    flex-shrink: 0;
    transition: transform .16s ease-in-out;
    will-change: transform;
}

.input-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

.input-stack {
    position: relative;
    width: 100%;
    min-height: 1.5rem;
}

.composer-input,
.command-highlight {
    width: 100%;
    color: var(--txt);
    font: inherit;
    line-height: 1.5;
    letter-spacing: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.composer-input {
    position: relative;
    z-index: 2;
    display: block;
    height: 1.5rem;
    min-height: 1.5rem;
    max-height: var(--composer-input-max-height, 66vh);
    overflow: hidden;
    color: transparent;
    caret-color: var(--txt);
}

.composer-input::placeholder {
    color: var(--txt4);
}

.command-highlight {
    position: absolute;
    inset: 0;
    z-index: 1;
    max-height: var(--composer-input-max-height, 66vh);
    overflow: hidden;
    pointer-events: none;
}

.shortcuts {
    color: var(--txt4);
}

.description-files {
    color: var(--txt);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.attachment-remove {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: .12em;
}

.sent-with {
    margin: 0;
    color: var(--txt4);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.command-help-command {
    color: var(--accent);
}

.command-help-key {
    color: var(--txt);
}

.command-help-desc {
    color: var(--txt4);
}

/* ── App Header ── */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 3rem;
    background: var(--bg);
    cursor: pointer;
    user-select: none;
}

.header-inner {
    max-width: 52rem;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
}

.header-session-toggle {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex: 1;
    min-width: 0;
}

.profile-avatar {
    min-width: 1.25rem;
    height: 1.25rem;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.sign-in-button {
    color: var(--txt);
    text-decoration: underline;
    text-underline-offset: .12em;
    white-space: nowrap;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-placeholder {
    font-size: .6rem;
    color: var(--txt4);
    line-height: 1;
}

.header-session-title {
    color: var(--txt4);
    min-width: 0;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-session-arrow {
    color: var(--txt4);
    flex-shrink: 0;
}

.app-header.is-open .header-session-title,
.app-header.is-open .header-session-arrow {
    color: var(--txt);
}

/* ── Session Overlay ── */

.session-overlay {
    position: fixed;
    top: 2rem;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99;
    background: var(--bg);
    overflow-y: auto;
    padding: .75rem 1rem 2rem;
    display: none;
}

.session-overlay.is-open {
    display: block;
    animation: overlaySlideIn .14s ease-out;
}

@keyframes overlaySlideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.session-list {
    display: flex;
    flex-direction: column;
    max-width: 50rem;
    margin: 0 auto;
}

.session-empty {
    color: var(--txt4);
    padding: .25rem 0;
}

.session-item {
    display: flex;
    align-items: baseline;
    padding: .3rem 0;
    border-bottom: solid .05rem var(--txt1);
    gap: 1rem;
    cursor: pointer;
}

.session-item-main {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.session-item:hover .session-item-title {
    text-decoration: underline;
}

.session-item-title {
    color: var(--txt4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.session-item.is-current .session-item-title {
    color: var(--txt);
}

.session-item-date {
    color: var(--txt3);
    white-space: nowrap;
    flex-shrink: 0;
}

.session-item-delete {
    color: var(--txt3);
    line-height: 1;
    flex-shrink: 0;
}

.session-item-delete:hover {
    color: var(--accent);
}
