/* Chat Page Styles */
:root {
    --inspector-expanded-width: 360px;
    --inspector-collapsed-width: 64px;
    --chat-header-height: 64px;
}

.thread-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.artifact-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background-color: #fff;
}

.artifact-page-label {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
}

.artifact-page-title {
    margin: 0.2rem 0 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.artifact-page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Inspector Panel */
.inspector-panel {
    flex: 0 0 var(--inspector-expanded-width);
    width: var(--inspector-expanded-width);
    max-width: var(--inspector-expanded-width);
    background-color: #ffffff;
    border-left: 1px solid #e5e7eb;
    padding: 0 1.25rem 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    row-gap: .5rem;
    transition: width 0.2s ease;
    position: relative;
}

.inspector-panel.collapsed {
    flex: 0 0 var(--inspector-collapsed-width);
    width: var(--inspector-collapsed-width);
    max-width: var(--inspector-collapsed-width);
    min-width: var(--inspector-collapsed-width);
    padding: 0 0.5rem 0.75rem;
    overflow: hidden;
    align-items: center;
}

.inspector-panel.expanded {
    min-width: 320px;
}

.inspector-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}

.inspector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 64px;
    padding: 0;
}

.inspector-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.inspector-header p {
    margin: 0.15rem 0 0;
    color: #6b7280;
    font-size: 0.75rem;
}

.inspector-collapse-toggle {
    margin-left: auto;
}

.inspector-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.inspector-section {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background-color: #f9fafb;
    overflow: hidden;
}

.inspector-section-header {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.inspector-section-header:hover,
.inspector-section-header:focus-visible {
    background-color: #eef2ff;
}

.inspector-section-text h4 {
    margin: 0;
    font-size: 0.95rem;
    color: #0f172a;
}

.inspector-section-text p {
    margin: 0.15rem 0 0;
    color: #6b7280;
    font-size: 0.8rem;
}


.inspector-section-body {
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.inspector-debug-card {
    border: 1px solid #a78bfa;
    border-radius: 0.9rem;
    padding: 1rem;
    background: linear-gradient(145deg, #312e81, #1e1b4b);
    color: #f8fafc;
    box-shadow: 0 15px 35px rgba(49, 46, 129, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.inspector-debug-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.debug-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inspector-debug-card-header h4 {
    margin: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #c7d2fe;
}

.inspector-debug-card-header p {
    margin: 0.2rem 0 0;
    color: #e0e7ff;
    font-size: 0.85rem;
}

.debug-json-preview {
    background-color: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(199, 210, 254, 0.35);
    border-radius: 0.65rem;
    padding: 0.75rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    max-height: 260px;
    overflow: auto;
    color: #f8fafc;
}

.debug-json-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #e0e7ff;
}

.debug-json-error {
    padding: 0.65rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(248, 113, 113, 0.8);
    background-color: rgba(127, 29, 29, 0.4);
    color: #fecaca;
    font-size: 0.82rem;
}

.debug-follow-button,
.debug-copy-button {
    border: 1px solid rgba(196, 181, 253, 0.6);
    color: #ede9fe;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.debug-follow-button {
    background-color: rgba(79, 70, 229, 0.2);
}

.debug-copy-button {
    background-color: rgba(15, 23, 42, 0.55);
}

.debug-follow-button:hover,
.debug-follow-button:focus-visible,
.debug-copy-button:hover,
.debug-copy-button:focus-visible {
    border-color: #c084fc;
    background-color: rgba(129, 140, 248, 0.45);
}

.inspector-panel.collapsed .inspector-header-text,
.inspector-panel.collapsed .inspector-body {
    display: none;
}

.inspector-panel.collapsed .inspector-debug-card {
    display: none;
}

.inspector-collapsed-label {
    display: none;
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.35em;
}

.inspector-panel.collapsed .inspector-collapsed-label {
    display: block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-weight: 600;
}

@media (max-width: 1200px) {
    .thread-layout {
        gap: 0;
    }

    .inspector-panel {
        flex: 0 0 var(--inspector-collapsed-width);
        width: var(--inspector-collapsed-width);
        max-width: var(--inspector-collapsed-width);
        min-width: var(--inspector-collapsed-width);
    }

    .inspector-panel.expanded {
        flex: 0 0 300px;
        width: 300px;
        max-width: 300px;
        min-width: 300px;
    }
}

@media (max-width: 1024px) {
    .thread-layout {
        flex-direction: column;
    }

    .inspector-collapse-toggle {
        display: none;
    }

    .chat-container {
        width: 100%;
    }

    .inspector-panel,
    .inspector-panel.collapsed,
    .inspector-panel.expanded {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        flex: 0 0 auto;
        width: min(90vw, 360px);
        max-width: 90vw;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: none;
        z-index: 1100;
        pointer-events: none;
        padding: 1.25rem;
    }

    body.inspector-drawer-open .inspector-panel {
        transform: translateX(0);
        pointer-events: auto;
        box-shadow: -25px 0 45px rgba(15, 23, 42, 0.25);
    }

    body.inspector-drawer-open .inspector-panel.collapsed {
        align-items: stretch;
    }

    body.inspector-drawer-open .inspector-panel.collapsed .inspector-header-text,
    body.inspector-drawer-open .inspector-panel.collapsed .inspector-body {
        display: flex;
        flex-direction: column;
    }

    .inspector-collapsed-label,
    .inspector-panel.collapsed .inspector-collapsed-label {
        display: none !important;
    }
}

.thread-layout {
    flex: 1;
    display: flex;
    min-height: 0;
    background-color: #f8fafc;
}

.chat-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.dictation-error-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid #f77171;
    background-color: #fff6f6;
    color: #b42318;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.dictation-error-dismiss {
    border: none;
    background: transparent;
    color: inherit;
    font-weight: 600;
    cursor: pointer;
}

.execution-error-banner {
    margin: 0.5rem 0 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #fca5a5;
    background-color: #fef2f2;
    color: #991b1b;
    font-size: 0.875rem;
    line-height: 1.4;
}

.execution-error-banner strong {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
}

.chat-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    min-height: var(--chat-header-height);
    padding: 0 1rem;
    display: flex;
    align-items: center;
}

.thread-settings-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 12;
}

.thread-settings-layer .thread-settings-scrim {
    position: absolute;
    top: var(--chat-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.thread-settings-layer.open {
    pointer-events: auto;
}

.thread-settings-layer.open .thread-settings-scrim {
    opacity: 1;
}

.thread-settings-drawer {
    position: absolute;
    top: var(--chat-header-height);
    left: 0;
    right: 0;
    width: min(720px, calc(100% - 2rem));
    margin: 0 auto;
    background-color: #ffffff;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
    border-top: 1px solid #e2e8f0;
    padding: 1.5rem;
    box-shadow: 0 35px 70px rgba(15, 23, 42, 0.25);
    transform: translate3d(0, -16px, 0);
    transition: transform 0.3s ease, opacity 0.2s ease;
    opacity: 0;
    will-change: transform, opacity;
    max-height: calc(100% - var(--chat-header-height));
    overflow-y: auto;
}

.thread-settings-layer.open .thread-settings-drawer {
    transform: translate3d(0, 0, 0);
    opacity: 1;
}

.thread-participants-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 13;
}

.thread-participants-layer .thread-participants-scrim {
    position: absolute;
    top: var(--chat-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.thread-participants-layer.open {
    pointer-events: auto;
}

.thread-participants-layer.open .thread-participants-scrim {
    opacity: 1;
}

.thread-participants-drawer {
    position: absolute;
    top: var(--chat-header-height);
    left: 0;
    right: 0;
    width: min(720px, calc(100% - 2rem));
    margin: 0 auto;
    background-color: #ffffff;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
    border-top: 1px solid #e2e8f0;
    padding: 1.5rem;
    box-shadow: 0 35px 70px rgba(15, 23, 42, 0.25);
    transform: translate3d(0, -16px, 0);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.2s ease;
    max-height: calc(100% - var(--chat-header-height));
    overflow-y: auto;
}

.thread-participants-layer.open .thread-participants-drawer {
    transform: translate3d(0, 0, 0);
    opacity: 1;
}

.thread-participants-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.thread-participants-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #0f172a;
}

.thread-participants-header p {
    margin: 0.2rem 0 0;
    color: #64748b;
    font-size: 0.9rem;
}

.thread-participants-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.thread-participants-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.thread-participants-row:last-child {
    border-bottom: none;
}

.thread-participants-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #eef2ff;
    color: #1d4ed8;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.thread-participants-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.thread-participants-name {
    font-weight: 600;
    color: #0f172a;
}

.thread-participants-meta {
    font-size: 0.85rem;
    color: #64748b;
}

.participants-drawer-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 13;
}

.participants-drawer-layer .participants-drawer-scrim {
    position: absolute;
    top: var(--chat-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.25);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.participants-drawer-layer.open {
    pointer-events: auto;
}

.participants-drawer-layer.open .participants-drawer-scrim {
    opacity: 1;
}

.participants-drawer {
    position: absolute;
    top: var(--chat-header-height);
    right: 1rem;
    width: min(360px, calc(100% - 1.5rem));
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
    transform: translate3d(0, -16px, 0);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.participants-drawer-layer.open .participants-drawer {
    transform: translate3d(0, 0, 0);
    opacity: 1;
}

.participants-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.participants-drawer-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.participants-drawer-header p {
    margin: 0.2rem 0 0;
    color: #64748b;
    font-size: 0.9rem;
}

.participants-drawer-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.participants-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.participants-row:last-child {
    border-bottom: none;
}

.participants-row-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #eef2ff;
    color: #1d4ed8;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.participants-row-details {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.participants-row-name {
    font-weight: 600;
    color: #0f172a;
}

.participants-row-attr {
    font-size: 0.85rem;
    color: #64748b;
}

.thread-settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.thread-settings-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #0f172a;
}

.thread-settings-header p {
    margin: 0.2rem 0 0;
    color: #64748b;
    font-size: 0.9rem;
}

.drawer-close {
    border: none;
    background: transparent;
    color: #475467;
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.drawer-close:hover,
.drawer-close:focus-visible {
    background-color: #eef2ff;
    color: #1f2937;
}

.drawer-close:focus-visible {
    outline: 2px solid #c7d2fe;
    outline-offset: 2px;
}

.thread-settings-body {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.thread-settings-empty {
    margin: 0;
    color: #475467;
    font-size: 0.95rem;
}

.drawer-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem 1.25rem;
}

.drawer-section.drawer-danger-zone {
    background: #fef2f2;
    border-color: #fecaca;
}

.drawer-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.drawer-section-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #0f172a;
}

.drawer-section-header p {
    margin: 0.2rem 0 0;
    font-size: 0.9rem;
    color: #64748b;
}

.drawer-chip {
    padding: 0.15rem 0.75rem;
    border-radius: 999px;
    background-color: #e0e7ff;
    color: #3730a3;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.read-only-execution {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.read-only-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.inline-edit-trigger {
    border: 1px solid #c7d2fe;
    background-color: #eef2ff;
    border-radius: 0.75rem;
    padding: 0.65rem 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #1f2937;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.inline-edit-trigger:hover,
.inline-edit-trigger:focus-visible {
    background-color: #e0e7ff;
    border-color: #a5b4fc;
}

.inline-edit-trigger:focus-visible {
    outline: 2px solid #c7d2fe;
    outline-offset: 2px;
}

.inline-edit-icon {
    font-size: 0.85rem;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.inline-edit-trigger:hover .inline-edit-icon,
.inline-edit-trigger:focus-visible .inline-edit-icon {
    opacity: 1;
}

.drawer-help-text {
    margin: 0;
    font-size: 0.85rem;
    color: #475467;
}

.drawer-danger-button {
    border: 1px solid #f87171;
    background-color: #dc2626;
    color: #ffffff;
    font-weight: 600;
    padding: 0.65rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    align-self: flex-start;
}

.drawer-danger-button:hover,
.drawer-danger-button:focus-visible {
    background-color: #b91c1c;
    border-color: #b91c1c;
}

.drawer-danger-button:focus-visible {
    outline: 2px solid #fecaca;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .thread-settings-drawer {
        width: 100%;
        left: 0;
        right: 0;
        border-bottom-left-radius: 0.75rem;
        border-bottom-right-radius: 0.75rem;
        padding: 1.25rem;
    }
}

.drawer-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.drawer-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.drawer-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.loading {
    text-align: center;
    color: #666;
    font-size: 1rem;
}

/* Chat Window Container */
.chat-window {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    position: relative;
}

.chat-window-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Loading State */
.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #555;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #999;
    font-size: 1rem;
}

/* Messages Area */
.messages-area,
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

/* Scroll-to-bottom button (ChatGPT-style) */
.scroll-to-bottom-button {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	bottom: 7.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background-color: #ffffff;
    box-shadow: 0 10px 15px rgba(15, 23, 42, 0.15);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.scroll-to-bottom-button:hover {
    background-color: #f3f4f6;
}

/* Chat Message Styles - v0.3 with role support */
.chat-message {
    display: flex;
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease-in;
    position: relative;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Message Avatar (U for user, A for assistant) */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background-color: #2563eb;
    color: white;
}

.assistant-message .message-avatar {
    background-color: #6b7280;
    color: white;
}

/* Message Bubble */
.message-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.2rem;
    min-width: 0;
}

.chat-message.user-message .message-body {
    align-items: flex-end;
}

.message-bubble {
    display: flex;
    flex-direction: column;
    padding: 0.65rem 0.95rem;
    border-radius: 1rem;
    flex: 1;
    border: 1px solid transparent;
}

/* User Message - Right aligned with blue bubble */
.chat-message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
    max-width: 75%;
}

.user-message .message-bubble {
    background-color: #f3f4f6;
    color: #0f172a;
    border-color: #e5e7eb;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* Assistant Message - Left aligned with gray bubble */
.chat-message.assistant-message {
    align-self: stretch;
    flex-direction: row;
    margin-right: auto;
    padding: 0.25rem 0;
    max-width: 85%;
}

.assistant-message .message-bubble {
    background-color: transparent;
    border-color: transparent;
    padding: 0;
    border-radius: 0;
    max-width: 100%;
    min-width: 0;
}
.assistant-message .message-content {
    font-size: 1rem;
    color: #0f172a;
    padding-right: 2rem;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* System Message - Left aligned with gray bubble like assistant */
.chat-message.system-message {
    align-self: stretch;
    flex-direction: row;
    margin-right: auto;
    padding: 0.25rem 0;
    max-width: 85%;
}

.system-message .message-avatar {
    background-color: #f59e0b;
    color: white;
    font-size: 0.875rem;
}

.system-message .message-bubble {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    padding: 0.65rem 0.95rem;
    border-radius: 1rem;
}

.system-message .message-content {
    font-size: 0.9rem;
    color: #0f172a;
}

.system-message .message-timestamp {
    color: #9ca3af;
    font-size: 0.75rem;
}

/* Notice Message - Centered, grey, no bubble */
.chat-message.notice-message {
    align-self: center;
    color: #6b7280;
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    padding: 0.5rem;
    max-width: 100%;
}

/* Message Content */
.message-content {
    font-size: 0.95rem;
    line-height: 1.5;
}
    .message-content h3, .message-content h2, .message-content p {
        margin-block-start: 0em;
        margin-block-end: 0em;
    }

.message-content.message-markdown {
    white-space: normal;
}

.message-content.message-markdown pre {
    white-space: pre-wrap;
}

.message-content.message-ingestion {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.message-ingestion-blocks {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.message-ingestion-block {
    padding: 0 0 5px 0;
    margin: 0;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* Message Timestamp + Actions Row */
.message-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.1rem;
}

.user-message .message-meta-row {
    justify-content: flex-end;
    flex-direction: row-reverse;
    align-self: flex-end;
}

.assistant-message .message-meta-row {
    justify-content: flex-start;
}

.message-timestamp {
    font-size: 0.75rem;
    opacity: 0.8;
}

.user-message .message-timestamp {
    color: #4b5563;
    text-align: right;
}

.assistant-message .message-timestamp {
    color: #9ca3af;
}

.system-message .message-timestamp {
    color: #6b7280;
    font-size: 0.65rem;
}

/* Message action bar */
.message-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(2px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-message:hover .message-action-bar:not(.block-action-bar) {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.message-action {
    border: none;
    background: transparent;
    padding: 0.3rem;
    border-radius: 0.4rem;
    cursor: pointer;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.message-action:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.message-action.dev-debug-action {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.65rem;
    border: 1px dashed rgba(79, 70, 229, 0.5);
    border-radius: 999px;
    background-color: rgba(99, 102, 241, 0.08);
    color: #4338ca;
}

.message-action.dev-debug-action:hover {
    background-color: rgba(99, 102, 241, 0.18);
    border-color: rgba(67, 56, 202, 0.8);
    color: #312e81;
}

.message-action svg {
    width: 15px;
    height: 15px;
}

.message-action.prompt-input-toggle {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    min-width: 32px;
}

.message-action.prompt-input-toggle.active {
    background-color: #111827;
    color: #f9fafb;
}

.message-action.interpretation-toggle {
    border: 1px solid transparent;
}

.message-action.interpretation-toggle.active {
    background-color: #0f172a;
    color: #f8fafc;
    border-color: #0f172a;
}

.prompt-input-view {
    background-color: #0f172a;
    color: #f8fafc;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    border-radius: 0.75rem;
    padding: 0.75rem 0.95rem;
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.35);
}

/* Day Divider */
.day-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0 1rem 0;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    width: 100%;
}

.day-divider span {
    padding: 0 1rem;
    background-color: white;
    position: relative;
    z-index: 1;
}

.day-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #e5e7eb;
    top: 50%;
    transform: translateY(-50%);
}

/* Input Area */
.input-area,
.chat-window-footer {
    border-top: 1px solid #e5e7eb;
    padding: 1rem;
    background-color: white;
}

/* Input Bar Styling */
.input-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

.quoted-context-panel {
    width: 100%;
    border: 1px solid #dfe3f0;
    border-radius: 0.9rem;
    padding: 0.75rem 1rem;
    background: #f7f9ff;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
}

.quoted-context-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
}

.quoted-context-panel-count {
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-weight: 600;
    font-size: 0.7rem;
}

.quoted-context-list {
    list-style: none;
    padding: 0;
    margin: 0.6rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quoted-context-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.45rem 0.5rem;
    border-radius: 0.65rem;
    background: #fff;
    border: 1px solid #e4e7ee;
}

.quoted-context-body {
    flex: 1;
    min-width: 0;
}

.quoted-context-text {
    margin: 0;
    font-size: 0.9rem;
    color: #0f172a;
    font-style: italic;
    line-height: 1.4;
}

.quoted-context-meta {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: #64748b;
}

.quoted-context-dismiss {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.35rem;
    padding: 0.15rem 0.35rem;
    line-height: 1;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.quoted-context-dismiss:hover,
.quoted-context-dismiss:focus-visible {
    background-color: #e2e8f0;
    color: #0f172a;
}

.message-input-wrapper {
    position: relative;
    display: flex;
    flex: 1;
}

.message-input-wrapper.dictation-active .message-input {
    color: transparent;
    caret-color: transparent;
    pointer-events: none;
}

.message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    padding-right: 7.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 260px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.message-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-accessories {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    z-index: 3;
}

.input-icon-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    max-width: 36px;
    max-height: 36px;
    line-height: 0;
    flex: 0 0 36px;
    box-sizing: border-box;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.input-icon-button svg {
    width: 20px;
    height: 20px;
}

.input-icon-button:hover:not(:disabled) {
    background-color: #eef2ff;
    color: #111827;
}

.input-icon-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-icon-button.send-button {
    background-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 10px 15px rgba(37, 99, 235, 0.2);
}

.input-icon-button.send-button:hover:not(:disabled) {
    background-color: #1d4ed8;
}

.input-icon-button.send-button:disabled {
    background-color: #9ab5ff;
    color: #f5f7ff;
    box-shadow: none;
    opacity: 0.7;
}

.chat-window-footer {
    flex-shrink: 0;
}

.dictation-error-overlay {
    position: absolute;
    top: 0.3rem;
    left: 0.9rem;
    z-index: 2;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.15);
    max-width: calc(100% - 1.8rem);
    pointer-events: auto;
}


.dictation-overlay {
    position: absolute;
    top: 0.3rem;
    bottom: 0.3rem;
    left: 0.35rem;
    right: 0.35rem;
    border-radius: 0.5rem;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.35rem 0.65rem;
    z-index: 2;
    pointer-events: none;
}

.dictation-overlay.recording {
    right: 5.1rem;
    padding-right: 1rem;
}


.dictation-overlay.recording .dictation-waveform {
    flex: 1;
    width: 100%;
    min-height: 32px;
    transform: translateY(-1px);
}

.dictation-overlay.recording .waveform-bars {
    width: 100%;
    height: 32px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}

.dictation-overlay.recording .waveform-bar {
    flex: 1;
}

.dictation-overlay.recording .dictation-timer {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.dictation-overlay.transcribing {
    justify-content: center;
    right: 5.1rem;
}

.dictation-status-inline {
    font-size: 0.88rem;
    color: #374151;
}
.button-spinner.overlay {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.input-icon-button.stop-button {
    position: relative;
    width: 36px;
    height: 36px;
    overflow: hidden;
}

.input-icon-button.stop-button.loading svg {
    opacity: 0.2;
}

.input-icon-button.stop-button.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    margin-left: -5px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    pointer-events: none;
}

.input-icon-button.stop-button.loading:disabled {
    opacity: 1;
    cursor: default;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar,
.messages-area::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.messages-area::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.chat-messages::-webkit-scrollbar-thumb,
.messages-area::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.messages-area::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: #f3f4f6;
    border-radius: 1rem;
    margin-right: auto;
    animation: fadeIn 0.2s ease-in;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-text {
    font-size: 0.85rem;
    color: #6b7280;
    font-style: italic;
    margin-left: 0.25rem;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Disabled textarea styling */
.message-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Responsive Design for Mobile Devices */
@media (max-width: 768px) {
    .chat-window {
        max-width: 100%;
    }
    
    .chat-message.user-message {
        max-width: 85%;
        font-size: 0.9rem;
    }

    .message-avatar {
        background-color: #2563eb;
        color: white;
    }

    .message-bubble {
        padding: 0.6rem 0.85rem;
    }
    
    .messages-area,
    .chat-messages {
        padding: 1rem 0.75rem;
        gap: 0.75rem;
    }
    
    .message-content {
        font-size: 0.9rem;
    }

    .day-divider {
        margin: 1rem 0 0.75rem 0;
        font-size: 0.7rem;
    }
    
    .input-area,
    .chat-input {
        padding: 0.75rem;
    }
    
    .input-bar {
        gap: 0.5rem;
    }
    
    .message-input {
        padding: 0.6rem 0.85rem;
        font-size: 0.9rem;
        min-height: 40px;
    }
    
    .send-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .typing-indicator {
        max-width: 180px;
    }
    
    .typing-text {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .chat-message.user-message {
        max-width: 90%;
        font-size: 0.85rem;
    }

    .message-avatar {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .message-bubble {
        padding: 0.6rem 0.85rem;
    }
    
    .message-content {
        font-size: 0.85rem;
    }
    
    .message-timestamp {
        font-size: 0.65rem;
    }

    .system-message {
        font-size: 0.8rem;
        padding: 0.5rem 0.65rem;
    }

    .notice-message {
        font-size: 0.8rem;
    }

    .day-divider {
        margin: 0.75rem 0 0.5rem 0;
        font-size: 0.65rem;
    }
    
    .messages-area,
    .chat-messages {
        padding: 0.75rem 0.5rem;
        gap: 0.6rem;
    }
    
    .input-area,
    .chat-input {
        padding: 0.6rem;
    }
    
    .input-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .message-input {
        width: 100%;
    }
    
    .send-button {
        width: 100%;
        padding: 0.75rem;
    }
    
    .chat-loading,
    .chat-empty {
        padding: 2rem 1rem;
        font-size: 0.9rem;
    }
    
    .typing-indicator {
        max-width: 150px;
        padding: 0.6rem 0.85rem;
    }
}

/* Quoted context preview */
.quoted-context-preview {
    align-self: flex-end;
    max-width: 70%;
    background-color: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 0.85rem;
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    color: #1e293b;
    line-height: 1.35;
    box-shadow: 0 5px 12px rgba(99, 102, 241, 0.08);
}

.chat-message.assistant-message .quoted-context-preview {
    align-self: flex-start;
}

.quote-action-bubble {
    position: fixed;
    transform: translate(-50%, -140%);
    z-index: 1500;
    pointer-events: auto;
}

.quote-action-button {
    pointer-events: auto;
    border: none;
    border-radius: 999px;
    background: #111827;
    color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.25);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.quote-action-button:hover,
.quote-action-button:focus-visible {
    background: #1d4ed8;
    color: #ffffff;
    outline: none;
}

.quoted-context-label {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.65rem;
    color: #475569;
    margin-bottom: 0.15rem;
}

.interpretation-json-view {
    margin-top: 0.65rem;
    background-color: #0f172a;
    color: #f8fafc;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    white-space: pre-wrap;
    border-radius: 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    max-height: 320px;
    overflow-y: auto;
}

.interpretation-empty {
    margin-top: 0.65rem;
    font-size: 0.85rem;
    color: #475569;
    background-color: #f8fafc;
    border: 1px dashed #cbd5f5;
    border-radius: 0.75rem;
    padding: 0.6rem 0.85rem;
}

.m0-helper-text {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}

.m0-empty-state {
    border: 1px dashed #c7d2fe;
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    color: #475569;
    background-color: #f8fafc;
}

.m0-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.65rem;
    margin-bottom: 0.65rem;
}

.m0-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.m0-section h5 {
    margin: 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
}

.m0-field-value {
    font-size: 0.95rem;
    color: #0f172a;
}

.m0-tag-list {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.m0-tag {
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background-color: #eef2ff;
    color: #312e81;
    font-size: 0.75rem;
    font-weight: 600;
}

.m0-inline-muted {
    font-size: 0.75rem;
    color: #94a3b8;
}

.m0-list {
    margin: 0;
    padding-left: 1rem;
    color: #27303f;
    font-size: 0.9rem;
}

.m0-raw-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.m0-raw-button,
.m0-copy-button {
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    color: #1e1b4b;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.m0-raw-button:hover,
.m0-copy-button:hover,
.m0-raw-button:focus-visible,
.m0-copy-button:focus-visible {
    background-color: #e0e7ff;
    border-color: #a5b4fc;
}

.m0-raw-json {
    margin-top: 0.5rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    background-color: #0f172a;
    color: #f8fafc;
    border-radius: 0.75rem;
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    max-height: 240px;
    overflow-y: auto;
}

.inspector-section-body {
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.canonical-state-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.canonical-state-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.canonical-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.canonical-version-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background-color: #eef2ff;
    color: #312e81;
    font-size: 0.8rem;
    font-weight: 600;
}

.canonical-updated {
    font-size: 0.85rem;
    color: #475569;
}

.canonical-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.canonical-flag {
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.canonical-flag.flag-positive {
    background-color: #ecfccb;
    border-color: #bef264;
    color: #3f6212;
}

.canonical-flag.flag-warning {
    background-color: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.canonical-flag.flag-neutral {
    background-color: #f1f5f9;
    border-color: #cbd5f5;
    color: #475569;
}

.canonical-state-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.canonical-field {
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    padding: 0.6rem 0.75rem;
    background-color: #ffffff;
}

.canonical-field-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.canonical-field-value {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
    color: #0f172a;
    word-break: break-word;
}

.canonical-arrays {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.canonical-array {
    border: 1px solid #e5e7eb;
    border-radius: 0.65rem;
    padding: 0.6rem 0.75rem;
    background-color: #ffffff;
}

.canonical-array-list {
    margin: 0.35rem 0 0 1.25rem;
    padding: 0;
    color: #0f172a;
    font-size: 0.92rem;
    list-style: disc;
}

.canonical-array-empty {
    margin-top: 0.35rem;
    font-size: 0.88rem;
    color: #94a3b8;
    font-style: italic;
}

.canonical-raw-toggle-row {
    display: flex;
    justify-content: flex-end;
}

.canonical-raw-toggle {
    border: 1px solid #cbd5f5;
    background-color: #eef2ff;
    color: #312e81;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.canonical-raw-toggle:hover,
.canonical-raw-toggle:focus-visible {
    background-color: #e0e7ff;
    border-color: #a5b4fc;
}

.canonical-raw-json {
    margin: 0;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    background-color: #0f172a;
    color: #f8fafc;
    border-radius: 0.75rem;
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    max-height: 240px;
    overflow: auto;
}

.canonical-empty-state {
    font-size: 0.85rem; 
    color: #475569;
    background-color: #f8fafc;
    border: 1px dashed #cbd5f5;
}

.artifact-composer-panel {
    width: 100%;
    margin-bottom: 0.85rem;
    padding: 1rem;
    border: 1px solid #dfe3f0;
    border-radius: 0.9rem;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.artifact-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.artifact-field:last-of-type {
    margin-bottom: 0.5rem;
}

.artifact-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.artifact-input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 0.55rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.artifact-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.artifact-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #94a3b8 50%),
                      linear-gradient(135deg, #94a3b8 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.artifact-textarea {
    min-height: 64px;
    resize: vertical;
}

.artifact-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.artifact-action {
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.artifact-action.secondary {
    background: #f1f5f9;
    color: #475569;
}

.artifact-action.secondary:hover {
    background: #e2e8f0;
}

.artifact-action.primary {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

.artifact-action.primary:disabled {
    background: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}

.artifact-error {
    margin-bottom: 0.5rem;
    color: #b91c1c;
    font-size: 0.85rem;
}

.input-icon-button.artifact-trigger.active {
    background-color: #eef2ff;
    color: #1d4ed8;
}

.artifact-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    border: 1px solid #c7d2fe;
    background-color: #eef2ff;
    color: #312e81;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.artifact-thread-callout {
    display: flex;
    gap: 0.75rem;
    border: 1px solid #e0e7ff;
    border-radius: 0.85rem;
    padding: 0.75rem 1rem;
    background: #f8f9ff;
    margin-bottom: 1rem;
    align-items: flex-start;
}

.artifact-thread-title {
    margin: 0;
    font-weight: 600;
    color: #1e1b4b;
}

.artifact-thread-text {
    margin: 0.15rem 0 0;
    color: #475569;
    font-size: 0.85rem;
}

.related-artifacts-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.related-artifact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.related-artifact-row:hover,
.related-artifact-row:focus-visible {
    border-color: #c7d2fe;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.related-artifact-row-main {
    flex: 1;
    min-width: 0;
}

.related-artifact-row-title {
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.related-artifact-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #475569;
}

.related-artifact-chevron {
    font-size: 1.25rem;
    color: #94a3b8;
}

.related-artifacts-loading,
.related-artifacts-empty,
.related-artifacts-error {
    padding: 0.75rem;
    border: 1px dashed #d1d5db;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.related-artifacts-error {
    border-color: #fecaca;
    color: #b91c1c;
    background-color: #fef2f2;
}

.artifact-state-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.artifact-state-badge.state-running {
    background-color: #e0f2fe;
    color: #0369a1;
}

.artifact-state-badge.state-complete {
    background-color: #dcfce7;
    color: #166534;
}

.artifact-state-badge.state-failed {
    background-color: #fee2e2;
    color: #b91c1c;
}

.artifact-state-badge.state-idle {
    background-color: #f3f4f6;
    color: #475569;
}

.artifact-viewer {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
}

.artifact-content-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.artifact-header-left {
    flex: 1 1 320px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.artifact-header-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .artifact-header-right {
        width: 100%;
        align-items: flex-start;
    }
}

.artifact-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.artifact-title-label-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.artifact-title-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 600;
}

.artifact-title-editor {
    display: flex;
    align-items: center;
    min-height: 52px;
}

.artifact-title-display {
    border: none;
    background: transparent;
    padding: 0.15rem 0.4rem;
    margin: -0.15rem -0.4rem;
    font-size: 1.85rem;
    font-weight: 700;
    color: #0f172a;
    text-align: left;
    width: 100%;
    border-radius: 0.65rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.artifact-title-display:hover,
.artifact-title-display:focus-visible {
    background-color: #f8fafc;
    color: #0f172a;
    outline: none;
}

.artifact-title-display:focus-visible {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.35);
}

.artifact-title-input {
    width: 100%;
    border: none;
    border-bottom: 2px solid #4338ca;
    font-size: 1.85rem;
    font-weight: 700;
    padding: 0.2rem 0;
    background: transparent;
    color: #0f172a;
}

.artifact-title-input:focus {
    outline: none;
    border-bottom-color: #312e81;
}

.artifact-title-input:disabled {
    border-bottom-color: #cbd5f5;
    opacity: 0.7;
}

.artifact-actions-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.artifact-inline-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.artifact-inline-action.success {
    background-color: #dcfce7;
    color: #166534;
}

.artifact-inline-action.warning {
    background-color: #fef3c7;
    color: #92400e;
}

.artifact-inline-action.neutral {
    background-color: #f1f5f9;
    color: #475569;
}

.artifact-inline-action.danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.artifact-inline-action.success:hover,
.artifact-inline-action.warning:hover,
.artifact-inline-action.neutral:hover,
.artifact-inline-action.danger:hover {
    opacity: 0.85;
}

.artifact-inline-action:focus-visible {
    outline: 2px solid #c7d2fe;
    outline-offset: 2px;
}

.artifact-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: 1px solid #cbd5f5;
    background-color: #f8faff;
    color: #312e81;
}

.artifact-badge.success {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.artifact-badge.warning {
    background-color: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.artifact-badge.neutral {
    background-color: #e2e8f0;
    border-color: #cbd5f5;
    color: #475569;
}

.artifact-inline-note {
    font-size: 0.8rem;
    color: #475467;
    background-color: #f8fafc;
    padding: 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.artifact-inline-note.success {
    border-color: #86efac;
    background-color: #dcfce7;
}

.artifact-inline-note.warning {
    border-color: #fcd34d;
    background-color: #fef3c7;
}

.artifact-inline-note.neutral {
    border-color: #cbd5f5;
    background-color: #f1f5f9;
}

.artifact-inline-note.danger {
    border-color: #fca5a5;
    background-color: #fee2e2;
}

.artifact-inline-note strong {
    font-weight: 700;
    color: inherit;
}

.artifact-inline-note svg {
    width: 1.2rem;
    height: 1.2rem;
    flex-shrink: 0;
}

.artifact-inline-note p {
    margin: 0;
    color: inherit;
    line-height: 1.4;
}

.artifact-inline-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.artifact-inline-action-group.success {
    background-color: #dcfce7;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.artifact-inline-action-group.warning {
    background-color: #fef3c7;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.artifact-inline-action-group.neutral {
    background-color: #f1f5f9;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.artifact-inline-action-group.danger {
    background-color: #fee2e2;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

/* Artifact Viewer scoped styles */
.artifact-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.artifact-viewer-body {
    flex: 1;
    padding: 1.5rem;
    background-color: #f8fafc;
    overflow: auto;
}

.artifact-state-card {
    border: 1px dashed #cbd5f5;
    border-radius: 1rem;
    background-color: #fff;
    padding: 2rem 1.5rem;
    text-align: center;
    color: #475467;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 220px;
    box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.08);
}

    .artifact-state-card.artifact-error {
        border-color: #fecaca;
        color: #b42318;
        background-color: #fff5f5;
    }

    .artifact-state-card.artifact-empty {
        border-style: solid;
    }

.artifact-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.artifact-content-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.08);
}

.artifact-content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1.5rem 1.75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.artifact-header-left,
.artifact-header-right {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 240px;
}

.artifact-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.artifact-title-label-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.artifact-title-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 600;
}

.artifact-type-chip {
    padding: 0.1rem 0.65rem;
    border-radius: 999px;
    background-color: #eef2ff;
    color: #3730a3;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.artifact-title-editor {
    display: flex;
}

.artifact-title-display {
    border: none;
    background: none;
    padding: 0;
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
    color: #0f172a;
    text-align: left;
    cursor: pointer;
}

    .artifact-title-display:hover,
    .artifact-title-display:focus-visible {
        color: #111827;
    }

.artifact-title-input {
    width: 100%;
    font-size: 1.65rem;
    font-weight: 600;
    border: 1px solid #cbd5f5;
    border-radius: 0.75rem;
    padding: 0.35rem 0.65rem;
}

.artifact-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
}

.artifact-inline-action {
    border: 1px solid #d0d7ec;
    border-radius: 999px;
    background-color: #ffffff;
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.45rem 1.15rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

    .artifact-inline-action:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    .artifact-inline-action.primary {
        background-color: #111827;
        color: #f8fafc;
        border-color: #111827;
    }

    .artifact-inline-action.ghost {
        background-color: transparent;
    }

    .artifact-inline-action.danger {
        background-color: #fee2e2;
        border-color: #fecaca;
        color: #b42318;
    }

    .artifact-inline-action.success {
        background-color: #dcfce7;
        border-color: #86efac;
        color: #14532d;
    }

    .artifact-inline-action.warning {
        background-color: #fef3c7;
        border-color: #fde047;
        color: #92400e;
    }

    .artifact-inline-action.neutral {
        background-color: #f1f5f9;
        border-color: #e2e8f0;
        color: #475569;
    }

.artifact-inline-note {
    border-radius: 0.65rem;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 500;
    background-color: #eef2ff;
    color: #3730a3;
}

    .artifact-inline-note.error {
        background-color: #fef2f2;
        color: #b42318;
    }

    .artifact-inline-note.warning {
        background-color: #fffbeb;
        color: #92400e;
    }

    .artifact-inline-note.success {
        background-color: #ecfdf5;
        color: #0f766e;
    }

.artifact-metadata-grid {
    padding: 1.5rem 1.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.artifact-meta-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.9rem;
    padding: 1.1rem 1.25rem;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100%;
}

.artifact-meta-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

    .artifact-meta-card-header h3 {
        margin: 0;
        font-size: 1rem;
        color: #0f172a;
    }

    .artifact-meta-card-header p {
        margin: 0.1rem 0 0;
        color: #64748b;
        font-size: 0.85rem;
    }

.artifact-meta-list {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.artifact-meta-item {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.95rem;
}

    .artifact-meta-item dt {
        margin: 0;
        color: #64748b;
        font-weight: 500;
    }

    .artifact-meta-item dd {
        margin: 0;
        color: #0f172a;
        font-weight: 600;
    }

.artifact-meta-sub {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: #475569;
}

.artifact-code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
    background-color: #0f172a;
    color: #f8fafc;
    padding: 0.2rem 0.5rem;
    border-radius: 0.4rem;
}

.artifact-badge {
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: 1px solid transparent;
}

    .artifact-badge.success {
        background-color: #dcfce7;
        border-color: #86efac;
        color: #166534;
    }

    .artifact-badge.warning {
        background-color: #fef3c7;
        border-color: #fcd34d;
        color: #92400e;
    }

    .artifact-badge.neutral {
        background-color: #e2e8f0;
        border-color: #cbd5f5;
        color: #475569;
    }

.artifact-persistence-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

    .artifact-persistence-details > div {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

.artifact-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 600;
}

.artifact-persistence-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.artifact-persist-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.artifact-field {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

    .artifact-field.full {
        flex-basis: 100%;
    }

    .artifact-field label {
        font-size: 0.85rem;
        font-weight: 600;
        color: #475467;
    }

        .artifact-field label .required {
            color: #b42318;
            font-weight: 700;
        }

    .artifact-field input {
        border: 1px solid #d0d7ec;
        border-radius: 0.65rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.95rem;
    }

.artifact-persist-actions {
    display: flex;
    gap: 0.75rem;
}

.artifact-content-body {
    padding: 1.5rem 1.75rem 1.75rem;
    border-top: 1px solid #e2e8f0;
    min-height: 0;
    overflow: auto;
}

.artifact-raw-text {
    margin: 0;
    background-color: #0f172a;
    color: #f8fafc;
    border-radius: 0.85rem;
    padding: 1rem 1.25rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.artifact-markdown {
    color: #0f172a;
    line-height: 1.65;
}

.artifact-status-control {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-end;
}

.artifact-status-chip {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #0f172a;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.artifact-status-chip .artifact-status-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
    color: #6b7280;
}

.artifact-status-chip .artifact-status-caret {
    font-size: 0.75rem;
    color: #94a3b8;
}

.artifact-status-chip.draft {
    background-color: #f1f5f9;
    border-color: #e2e8f0;
    color: #0f172a;
}

.artifact-status-chip.published {
    background-color: #ecfdf3;
    border-color: #bbf7d0;
    color: #166534;
}

.artifact-status-chip.archived {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    color: #6b7280;
}

.artifact-status-chip.busy {
    opacity: 0.75;
    cursor: progress;
}

.artifact-status-menu {
    position: absolute;
    top: 110%;
    right: 0;
    min-width: 180px;
    border: 1px solid #e2e8f0;
    border-radius: 0.6rem;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    padding: 0.35rem;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.artifact-status-option {
    border: none;
    background: #f8fafc;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.artifact-status-option:hover:not(:disabled),
.artifact-status-option:focus-visible:not(:disabled) {
    background-color: #eef2ff;
}

.artifact-status-option.active {
    background-color: #e0f2fe;
    color: #0ea5e9;
    cursor: default;
}

.artifact-status-option:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}