/* ── Chaos (Firehose) App — minimal chat UI ─── */

.chaos-app {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

/* ── Boot overlay (in-app) ─────────────────── */
.chaos-boot {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.chaos-boot.hidden { display: none; }

.chaos-boot-icon {
    font-size: 48px;
    animation: chaos-pulse 1.5s ease-in-out infinite;
}
@keyframes chaos-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.05); }
}

.chaos-boot-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.chaos-boot-progress {
    width: 220px;
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    overflow: hidden;
}
.chaos-boot-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s ease;
}

/* ── No provider notice ────────────────────── */
.chaos-no-provider {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 32px;
    text-align: center;
}
.chaos-no-provider h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}
.chaos-no-provider p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 360px;
    line-height: 1.5;
}
.chaos-setup-btn {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.chaos-setup-btn:hover { background: var(--accent-hover); }

/* ── Chat container ────────────────────────── */
.chaos-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Messages area ─────────────────────────── */
.chaos-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-surface) transparent;
}

/* ── Message bubbles ───────────────────────── */
.chaos-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.chaos-bubble.user {
    align-self: flex-end;
    background: var(--user-bubble);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}
.chaos-bubble.assistant {
    align-self: flex-start;
    background: var(--bg-surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chaos-bubble.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 12px;
}

/* Markdown inside assistant bubbles */
.chaos-bubble.assistant h1,
.chaos-bubble.assistant h2,
.chaos-bubble.assistant h3 {
    margin: 8px 0 4px;
    font-weight: 600;
}
.chaos-bubble.assistant h1 { font-size: 18px; }
.chaos-bubble.assistant h2 { font-size: 16px; }
.chaos-bubble.assistant h3 { font-size: 14px; }
.chaos-bubble.assistant p { margin: 4px 0; }
.chaos-bubble.assistant pre {
    background: var(--bg-primary);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 13px;
}
.chaos-bubble.assistant code {
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: 13px;
}
.chaos-bubble.assistant p code {
    background: var(--bg-primary);
    padding: 1px 5px;
    border-radius: 3px;
}
.chaos-bubble.assistant ul,
.chaos-bubble.assistant ol {
    padding-left: 20px;
    margin: 4px 0;
}
.chaos-bubble.assistant table {
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 13px;
}
.chaos-bubble.assistant th,
.chaos-bubble.assistant td {
    border: 1px solid var(--border);
    padding: 4px 8px;
}
.chaos-bubble.assistant th {
    background: var(--bg-hover);
    font-weight: 600;
}
.chaos-bubble.assistant a {
    color: var(--link);
    text-decoration: none;
}
.chaos-bubble.assistant hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

/* Model badge on assistant messages */
.chaos-model-badge {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

/* ── Thinking accordion ────────────────────── */
.chaos-thinking {
    align-self: flex-start;
    max-width: 85%;
    font-size: 13px;
    color: var(--text-muted);
}
.chaos-thinking-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}
.chaos-thinking-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: chaos-dot-pulse 1.2s ease-in-out infinite;
}
.chaos-thinking.done .chaos-thinking-dot {
    background: var(--text-muted);
    animation: none;
}
@keyframes chaos-dot-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}
.chaos-thinking-chevron {
    font-size: 10px;
    transition: transform 0.15s;
}
.chaos-thinking.expanded .chaos-thinking-chevron {
    transform: rotate(90deg);
}
.chaos-thinking-body {
    display: none;
    padding: 6px 0 6px 14px;
    white-space: pre-wrap;
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: 12px;
    color: var(--text-muted);
    max-height: 200px;
    overflow-y: auto;
}
.chaos-thinking.expanded .chaos-thinking-body {
    display: block;
}
.chaos-thinking-preview {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Action chips ──────────────────────────── */
.chaos-action-group {
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 0;
}
.chaos-action-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--bg-surface);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
}
.chaos-action-icon { font-size: 12px; }
.chaos-action-target {
    color: var(--text-muted);
    opacity: 0.7;
}

/* ── Spinner ───────────────────────────────── */
.chaos-spinner {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 4px 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.chaos-spinner.visible { display: flex; }
.chaos-spinner-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: chaos-dot-pulse 1.2s ease-in-out infinite;
}

/* ── Input bar ─────────────────────────────── */
.chaos-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}
.chaos-input-bar textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    outline: none;
    transition: border-color 0.15s;
}
.chaos-input-bar textarea:focus {
    border-color: var(--accent);
}
.chaos-input-bar textarea:disabled {
    opacity: 0.5;
}
.chaos-send-btn {
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.chaos-send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.chaos-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
