:root {
    --bg:        #1e1e1e;
    --fg:        #ddd;
    --fg-hover:  #fff;
    --border:    #000;
    --header-bg: #000;
    --header-hover: rgba(255,255,255,0.1);
}

.outputArea {
    width: 520px;
    max-width: 70vw;
    backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
}

.disclosure-group {
    max-width: 520px;
    min-width: 220px;
    margin: auto;
    /*margin-bottom: 20px;*/
    width: 100%;
}

/* Minimal disclosure styling */
.disclosure {
    border-left: 2px solid var(--border);
    margin-bottom: 1px;
    display: block;
    width: auto;
    /* animate border color and width */
    transition: border-color 0.2s ease, width 0.2s ease;
}
/* Change border-left when header hovered via JS class */
.disclosure.hover {
    border-left-color: var(--header-hover);
}
.disclosure-header {
    display: flex;
    align-items: center;
    background: var(--header-bg);
    padding: 4px 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    min-height: 24px;
    font-style: italic;
    /*margin-right: -12px;*/
}
.disclosure-header:hover {
    background: var(--header-hover);
}
.disclosure-header.no-hover:hover {
    background: var(--header-bg);
    cursor: default;
}
.disclosure-header .arrow {
    width: 0; height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid black;
    margin-right: 8px;
    transition: transform 0.2s ease, border-left-color 0.2s ease;
    opacity: 1.0;
    margin-left:-24px;
}
/* Red X mode when alt key is held */
.disclosure-header .arrow.remove-mode {
    border: none;
    width: 12px;
    height: 12px;
    position: relative;
    margin-right: 6px;
    margin-left: -26px;
}
.disclosure-header .arrow.remove-mode::before,
.disclosure-header .arrow.remove-mode::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 2px;
    background-color: #ff0000;
    /* Center the X lines vertically (half of 12px height minus half of 2px line height) */
    top: 5px;
    left: 0;
}
.disclosure-header .arrow.remove-mode::before {
    transform: rotate(45deg);
}
.disclosure-header .arrow.remove-mode::after {
    transform: rotate(-45deg);
}
.disclosure-header.hide-arrow .arrow { visibility: hidden; }
.disclosure-header:hover .arrow { border-left-color: var(--fg-hover); opacity:1; }
.disclosure.open .disclosure-header .arrow { transform: rotate(90deg); opacity:1; }
.disclosure-header .title { flex:1; font-size: 70%; padding-left: 6px;}

.disclosure {
    width: 200px;
    transition: none;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Content */
.disclosure-content {
    overflow: hidden;
    display: none;
    padding: 4px 4px;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.15);
    resize: none;
    box-sizing: border-box;
    width: auto;
}

.nested-canvas {
    position: relative;
    overflow: visible;
    min-width: 100%;
    min-height: 100%;
    width: 100000px;
    height: 100000px;
    transform-origin: 0 0;
    pointer-events: auto;
}

.disclosure-content iframe {
    width: 100% !important;
    height: 100% !important;
    border: 0;
    display: block;
    resize: none !important;
    box-sizing: border-box;
}

.disclosure-content.ai-chat-content {
    overflow: hidden;
    padding: 0;
    min-width: 550px;
}

.ai-chat-markdown {
    font-size: 11px;
    line-height: 1.35;
    color: var(--fg);
}

.ai-chat-markdown h1,
.ai-chat-markdown h2,
.ai-chat-markdown h3 {
    margin: 6px 0 4px 0;
    font-weight: 600;
    font-size: 12px;
    font-family: "iosevka";
}

.ai-chat-markdown p {
    margin: 4px 0;
}

.ai-chat-markdown ul {
    margin: 4px 0 4px 16px;
    padding: 0;
}

.ai-chat-markdown li {
    margin: 2px 0;
}

.ai-chat-markdown code {
    color: wheat;
    padding: 0 2px;
    border-radius: 0;
    font-family: "iosevka";
}

.ai-chat-markdown pre {
    /*background: rgba(0, 0, 0, 0.35);*/
    /*padding: 6px;*/
    border-radius: 6px;
    overflow: auto;
}

.ai-chat .hljs {
    background: black !important;
}
.ai-chat-code-block {
    position: relative;
    margin: 6px 0;
}

.ai-chat-code-block pre {
    margin: 0;
}

.ai-chat-copy-wrap {
    position: sticky !important;
    top: 6px;
    height: 0;
    z-index: 10;
}

.ai-chat-copy {
    position: absolute !important;
    top: 0;
    right: 6px;
    margin-left: 0;
    align-self: auto;
    width: 25px;
    height: 35px;
    background: rgba(0, 0, 0, 0.0) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15V5a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E") no-repeat center;
    color: var(--fg);
    border: 1px transparent;
    border-radius: 4px;
    opacity: 0.5;
    z-index: 10;
    font-size: 50%;
    transform: scale(0.8);
}

.ai-chat-copy:hover {
    opacity: 1;
}

.ai-chat-window {
    display: flex;
    flex-direction: column;
    /*gap: 6px;*/
    max-height: 30vh;
    overflow: hidden;
}

.ai-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    margin-left: 5px;
    padding-right: 5px;
}

.ai-chat-markdown p {
    padding-top: 4px;
    padding-bottom: 4px;
}

.ai-chat-input {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.ai-chat-input textarea {
    flex: 1 1 auto;
    background: rgba(0, 0, 0, 0.35);
    color: var(--fg);
    border: 1px solid rgba(72, 201, 255, 0.6);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 10px;
    /*resize: vertical;*/
    min-height: 96px;
    max-height: 120px;
    outline: none;
    margin: 5px;
    margin-right: 7px;
    resize: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.ai-chat-input textarea:focus {
    border-color: rgb(72, 201, 255);
    box-shadow: 0 0 0 1px rgba(72, 201, 255, 0.4);
}

.ai-chat-input {
    &::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    &::-webkit-scrollbar-thumb {
        background: rgba(1, 1, 1, 0.5);
        border-radius: 8px;
    }

    &::-webkit-scrollbar-track {
        background: transparent;
    }

    &::-webkit-scrollbar-button {
        display: none;
    }
}
.ai-chat-input button {
    background: rgba(255, 255, 255, 0.08);
    color: var(--fg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 0 10px;
    font-size: 10px;
    cursor: pointer;
}

.ai-chat-input button:hover {
    background: rgba(255, 255, 255, 0.18);
}

.ai-chat-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-turn {
    width: 100%;
    box-sizing: border-box;
    padding: 2px 6px;
}

.ai-chat-turn.ai {
    align-self: flex-start;
    text-align: left;
    margin-right: auto;
    border-left: 2px solid rgba(0,0,0, 1);
}

.ai-chat-turn.you {
    align-self: flex-end;
    text-align: right;
    margin-left: auto;
    border-right: 2px solid rgba(0,0,0, 1);
    font-style: italic;
}

.ai-chat-turn.you .ai-chat-markdown {
    text-align: right;
}

.ai-chat-turn.ai .ai-chat-markdown {
    text-align: left;
}

.ai-chat-turn.ai::before,
/* A request Field wrote itself (AiChatBlock.isFieldMessage): the outcome of builds a turn waited for. The model
   reads it as the next request; it sits on the agent's side, unslanted, so it does not read as yours. */
.ai-chat-turn.you.field {
    align-self: flex-start;
    text-align: left;
    margin-left: 0;
    margin-right: auto;
    border-right: none;
    border-left: 2px solid var(--ai-chat-summary-rule, var(--field-border));
    color: var(--ai-chat-summary-fg, var(--field-fg-muted));
    font-style: normal;
}

.ai-chat-turn.you.field .ai-chat-markdown {
    text-align: left;
    color: var(--ai-chat-summary-fg, var(--field-fg-muted));
}

.ai-chat-turn.you.field .ai-chat-turn-actions {
    justify-content: flex-start;
}

.ai-chat-turn.you::before {
    display: block;
    font-size: 9px;
    opacity: 0.6;
    margin-bottom: 2px;
}

.ai-chat-turn.ai::before {
    content: "GPT-5.2";
    text-align: left;
}

.ai-chat-turn.you::before {
    text-align: right;
}


.ai-chat-content {
    color: var(--fg);
    background: rgba(0,0,0,0.25);
}

.ai-chat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}

.ai-chat .history {
    max-height: 300px;
    overflow: auto;
    padding: 8px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
}

.ai-chat .input-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.ai-chat textarea {
    flex: 1;
    min-height: 80px;
    color: var(--fg);
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 8px;
    font-family: "iosevka", monospace;
}

.ai-chat button {
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    color: var(--fg);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    cursor: pointer;
}

.ai-chat button:hover {
    background: rgba(255,255,255,0.2);
}
