/* Maestro chat — правая панель в стиле Cursor */
:root {
    --omaestro-width: 400px;
    --omaestro-height: 50vh;
    --omaestro-bg: #18181b;
    --omaestro-border: #27272a;
    --omaestro-text: #ececec;
    --omaestro-muted: #8b8b93;
    --omaestro-input-bg: #09090b;
    --omaestro-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --omaestro-font-mono: 'JetBrains Mono', 'SF Mono', Consolas, 'Fira Code', ui-monospace, monospace;
    --omaestro-msg-size: 16px;
    --omaestro-msg-leading: 1.5;
    --omaestro-sidebar-size: 14px;
}

#orchestrator-maestro-dock,
#orchestrator-maestro-dock-floating {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    width: var(--omaestro-width);
    height: 100vh;
    max-height: 100vh;
    min-height: 0;
    flex-shrink: 0;
    background: var(--omaestro-bg);
    border-left: 1px solid var(--omaestro-border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    z-index: 120;
    font-family: var(--omaestro-font);
    font-size: var(--omaestro-msg-size);
    line-height: var(--omaestro-msg-leading);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.omaestro-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 10px;
    transform: translateX(-50%);
    cursor: col-resize;
    z-index: 6;
    touch-action: none;
    background: transparent;
}

.omaestro-resize-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 56px;
    border-radius: 999px;
    background: transparent;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.omaestro-resize-handle:hover::after,
.omaestro-resize-handle:focus-visible::after,
body.omaestro-resizing .omaestro-resize-handle::after {
    background: rgba(161, 161, 170, 0.65);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.omaestro-resize-handle:focus {
    outline: none;
}

.omaestro-resize-handle:focus-visible {
    outline: 1px solid rgba(161, 161, 170, 0.45);
    outline-offset: 2px;
}

body.omaestro-resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

body.omaestro-resizing * {
    cursor: col-resize !important;
}

body.workspace-maestro-shell:has(#orchestrator-maestro-dock),
body.feature-page.theme-video.workspace-maestro-shell,
body.eco-page:has(#orchestrator-maestro-dock):not(.main-embed-workspace):not(.workspace-embedded) {
    padding-right: var(--omaestro-width);
    box-sizing: border-box;
}

/* Fixed shell-header spans only the content column — not under Maestro dock */
body.eco-page:has(#orchestrator-maestro-dock):not(.main-embed-workspace):not(.workspace-embedded) .shell-header,
body.workspace-maestro-shell:has(#orchestrator-maestro-dock) .shell-header {
    right: var(--omaestro-width);
    width: auto;
}

body.eco-page:has(#orchestrator-maestro-dock):not(.main-embed-workspace):not(.workspace-embedded) .shell-header-inner,
body.workspace-maestro-shell:has(#orchestrator-maestro-dock) .shell-header-inner {
    max-width: none;
    width: 100%;
}

/* Lang switcher in shell-auth is in-flow; only offset legacy fixed mounts on eco pages */
body.eco-page:has(#orchestrator-maestro-dock):not(.main-embed-workspace):not(.workspace-embedded):not(.workspace-maestro-shell) .lang-switcher-mount[style*="position:fixed"],
body.eco-page:has(#orchestrator-maestro-dock):not(.main-embed-workspace):not(.workspace-embedded):not(.workspace-maestro-shell) .lang-switcher-mount[style*="position: fixed"] {
    right: calc(var(--omaestro-width) + 16px);
}

/* В iframe модуля чат живёт в parent shell v2 */
body.main-embed-workspace #orchestrator-maestro-dock,
body.workspace-embedded #orchestrator-maestro-dock,
body.workspace-embedded #orchestrator-maestro-dock-floating {
    display: none !important;
}

body.main-embed-workspace #main-page-chat-container {
    display: none !important;
}

/* Header */
.omaestro-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--omaestro-border);
    background: rgba(9, 9, 11, 0.72);
    flex-shrink: 0;
    min-height: 48px;
}

.omaestro-head-brand {
    min-width: 0;
}

.omaestro-head-title {
    font-size: var(--omaestro-sidebar-size);
    font-weight: 600;
    color: var(--omaestro-text);
    letter-spacing: -0.01em;
}

.omaestro-head-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--omaestro-muted);
    font-family: var(--omaestro-font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.omaestro-head-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.omaestro-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #a1a1aa;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}

.omaestro-icon-btn:hover {
    color: #fafafa;
    background: rgba(63, 63, 70, 0.55);
}

/* LLM setup */
.omaestro-setup-panel {
    display: none;
    position: relative;
    z-index: 4;
    padding: 12px 14px;
    border-bottom: 1px solid var(--omaestro-border);
    background: rgba(9, 9, 11, 0.55);
    gap: 8px;
    flex-shrink: 0;
    pointer-events: auto;
}

.omaestro-setup-panel.show {
    display: grid;
}

.omaestro-setup-panel input,
.omaestro-setup-panel select {
    width: 100%;
    background: var(--omaestro-input-bg);
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--omaestro-text);
    font-size: 12px;
}

.omaestro-setup-panel input:focus,
.omaestro-setup-panel select:focus {
    outline: none;
    border-color: #52525b;
}

.omaestro-setup-actions {
    display: flex;
    gap: 8px;
}

/* Intent Graph revisions */
.omaestro-revisions-panel {
    display: none;
    flex-direction: column;
    max-height: 220px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--omaestro-border);
    background: rgba(9, 9, 11, 0.55);
    flex-shrink: 0;
    overflow: hidden;
}

.omaestro-revisions-panel.show {
    display: flex;
}

.omaestro-revisions-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.omaestro-revisions-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--omaestro-muted);
}

.omaestro-revisions-refresh {
    border: none;
    background: transparent;
    color: var(--omaestro-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.omaestro-revisions-refresh:hover {
    color: var(--omaestro-text);
    background: rgba(63, 63, 70, 0.45);
}

.omaestro-revisions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    min-height: 0;
}

.omaestro-revision-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    background: rgba(24, 24, 27, 0.85);
}

.omaestro-revision-meta {
    min-width: 0;
    flex: 1;
}

.omaestro-revision-label {
    font-size: 12px;
    color: var(--omaestro-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.omaestro-revision-sub {
    font-size: 10px;
    color: var(--omaestro-muted);
    margin-top: 2px;
}

.omaestro-revision-rollback {
    flex-shrink: 0;
    border: 1px solid #52525b;
    background: #27272a;
    color: #fafafa;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.omaestro-revision-rollback:hover {
    background: #3f3f46;
}

.omaestro-revisions-empty,
.omaestro-revisions-loading {
    font-size: 12px;
    color: var(--omaestro-muted);
    padding: 8px 2px;
}

.omaestro-btn {
    flex: 1;
    border: 1px solid #3f3f46;
    background: #27272a;
    color: #d4d4d8;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
}

.omaestro-btn:hover {
    background: #3f3f46;
    color: #fafafa;
}

.omaestro-btn-primary {
    background: #fafafa;
    color: #18181b;
    border-color: #fafafa;
}

.omaestro-btn-primary:hover {
    background: #e4e4e7;
}

/* Banner */
.omaestro-banner {
    margin: 10px 14px 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(234, 179, 8, 0.22);
    background: rgba(234, 179, 8, 0.06);
    color: rgba(253, 224, 71, 0.92);
    font-size: 11px;
    line-height: 1.45;
    flex-shrink: 0;
}

.omaestro-banner.hidden {
    display: none;
}

.omaestro-nav-status {
    margin: 0 14px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.28);
    color: #e9d5ff;
    font-size: 12px;
    line-height: 1.4;
    flex-shrink: 0;
}

.omaestro-nav-status.hidden {
    display: none;
}

/* Messages */
.omaestro-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.omaestro-messages::-webkit-scrollbar {
    width: 6px;
}

.omaestro-messages::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 999px;
}

.omaestro-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 100%;
}

.omaestro-msg.user {
    align-items: flex-end;
}

.omaestro-msg.assistant .omaestro-bubble::before {
    content: 'Маэстро';
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--omaestro-muted);
    margin-bottom: 8px;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.omaestro-bubble {
    font-size: var(--omaestro-msg-size);
    line-height: var(--omaestro-msg-leading);
    font-weight: 400;
    letter-spacing: -0.011em;
    white-space: pre-wrap;
    word-break: break-word;
}

.omaestro-bubble p {
    margin: 0 0 0.75em;
}

.omaestro-bubble p:last-child {
    margin-bottom: 0;
}

.omaestro-bubble h1,
.omaestro-bubble h2,
.omaestro-bubble h3 {
    margin: 1em 0 0.5em;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.35;
    color: #f5f5f5;
}

.omaestro-bubble h1 { font-size: 1.375rem; }
.omaestro-bubble h2 { font-size: 1.25rem; }
.omaestro-bubble h3 { font-size: 1.125rem; }

.omaestro-bubble ul,
.omaestro-bubble ol {
    margin: 0.5em 0 0.75em;
    padding-left: 1.25em;
}

.omaestro-bubble li {
    margin: 0.25em 0;
}

.omaestro-bubble code {
    font-family: var(--omaestro-font-mono);
    font-size: 0.875em;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    padding: 0.1em 0.35em;
}

.omaestro-bubble pre {
    margin: 0.75em 0;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(9, 9, 11, 0.85);
    border: 1px solid #3f3f46;
    overflow-x: auto;
    font-family: var(--omaestro-font-mono);
    font-size: 13px;
    line-height: 1.55;
    color: #e4e4e7;
}

.omaestro-bubble pre code {
    background: transparent;
    padding: 0;
    font-size: inherit;
}

.omaestro-msg.assistant .omaestro-bubble {
    color: var(--omaestro-text);
    padding: 0;
    background: transparent;
    border: none;
}

.omaestro-msg.user .omaestro-bubble {
    max-width: 92%;
    background: #27272a;
    border: 1px solid #3f3f46;
    color: #f0f0f2;
    border-radius: 12px;
    padding: 11px 14px;
}

/* Composer — Cursor-style input shell */
.omaestro-composer {
    padding: 10px 12px 14px;
    border-top: 1px solid var(--omaestro-border);
    background: rgba(9, 9, 11, 0.72);
    flex-shrink: 0;
}

/* Unified Mode: Chat/Plan/Agent + Guided/Auto toggle rows
   (.omaestro-interaction-modes / .omaestro-execution-modes / .omaestro-mode-btn)
   were removed — the composer is single-row now (quick actions -> input shell). */
.omaestro-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.omaestro-quick button {
    border: 1px solid #3f3f46;
    background: transparent;
    color: #a1a1aa;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.omaestro-quick button:hover {
    color: #e4e4e7;
    border-color: #52525b;
    background: rgba(39, 39, 42, 0.65);
}

.omaestro-quick button.omaestro-quick-primary {
    color: #f4f4f5;
    border-color: rgba(163, 177, 138, 0.55);
    background: rgba(163, 177, 138, 0.14);
}

.omaestro-quick button.omaestro-quick-primary:hover {
    color: #fff;
    border-color: rgba(163, 177, 138, 0.85);
    background: rgba(163, 177, 138, 0.24);
}

.omaestro-input-shell {
    border: 1px solid #3f3f46;
    border-radius: 12px;
    background: var(--omaestro-input-bg);
    padding: 10px 12px 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.omaestro-input-shell:focus-within {
    border-color: #52525b;
    box-shadow: 0 0 0 1px rgba(82, 82, 91, 0.35);
}

.omaestro-input {
    display: block;
    width: 100%;
    min-height: 44px;
    max-height: 160px;
    resize: none;
    border: none;
    background: transparent;
    padding: 0;
    color: #f0f0f2;
    font-size: var(--omaestro-msg-size);
    line-height: var(--omaestro-msg-leading);
    font-family: inherit;
    letter-spacing: -0.011em;
}

.omaestro-input:focus {
    outline: none;
}

.omaestro-input::placeholder {
    color: #52525b;
}

.omaestro-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.omaestro-input-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.omaestro-attach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    background: #27272a;
    color: #a1a1aa;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.omaestro-attach-btn:hover:not(:disabled) {
    color: #fafafa;
    border-color: #52525b;
    background: #3f3f46;
}

.omaestro-attach-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.omaestro-media-attachment {
    margin-bottom: 8px;
}

.omaestro-media-attachment.hidden {
    display: none;
}

.omaestro-media-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    background: rgba(24, 24, 27, 0.9);
}

.omaestro-media-thumb {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #18181b;
}

.omaestro-media-thumb-video {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #e4e4e7;
}

.omaestro-media-name {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    color: #d4d4d8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.omaestro-media-clear {
    border: none;
    background: transparent;
    color: #a1a1aa;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}

.omaestro-media-clear:hover {
    color: #fafafa;
}

.omaestro-msg-media {
    margin-bottom: 8px;
}

.omaestro-msg-media img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    display: block;
}

.omaestro-msg-media-video {
    font-size: 12px;
    color: #d4d4d8;
}

.omaestro-input-hint {
    font-size: 10px;
    color: #52525b;
    font-family: ui-monospace, monospace;
}

.omaestro-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: #3f3f46;
    color: #a1a1aa;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.omaestro-send:not(:disabled) {
    background: #fafafa;
    color: #18181b;
}

.omaestro-send:not(:disabled):hover {
    background: #e4e4e7;
}

.omaestro-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 1100px) {
    #orchestrator-maestro-dock .omaestro-messages,
    #orchestrator-maestro-dock-floating .omaestro-messages {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 900px) {
    :root {
        --omaestro-msg-size: 15px;
    }

    #orchestrator-maestro-dock,
    #orchestrator-maestro-dock-floating {
        width: 100%;
        max-width: 100%;
        height: var(--omaestro-height);
    }

    body.eco-page:has(#orchestrator-maestro-dock):not(.main-embed-workspace):not(.workspace-embedded) .shell-header,
    body.workspace-maestro-shell:has(#orchestrator-maestro-dock) .shell-header {
        right: 0;
    }

    body.eco-page:has(#orchestrator-maestro-dock):not(.main-embed-workspace):not(.workspace-embedded),
    body.workspace-maestro-shell {
        padding-right: 0;
        padding-bottom: var(--omaestro-height);
    }

    body.eco-page:has(#orchestrator-maestro-dock):not(.workspace-maestro-shell) .lang-switcher-mount[style*="position:fixed"],
    body.eco-page:has(#orchestrator-maestro-dock):not(.workspace-maestro-shell) .lang-switcher-mount[style*="position: fixed"] {
        right: 16px;
    }

    #orchestrator-maestro-dock,
    #orchestrator-maestro-dock-floating {
        top: auto;
        bottom: 0;
        border-left: none;
        border-top: 1px solid var(--omaestro-border);
    }

    .omaestro-resize-handle {
        left: 0;
        right: 0;
        top: 0;
        bottom: auto;
        width: 100%;
        height: 12px;
        transform: none;
        cursor: row-resize;
    }

    .omaestro-resize-handle::after {
        width: 56px;
        height: 2px;
    }

    body.omaestro-resizing,
    body.omaestro-resizing * {
        cursor: row-resize !important;
    }
}

/* Video Director toolbar (workspace embed) */
.omaestro-video-toolbar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--omaestro-border);
    background: rgba(9, 9, 11, 0.65);
    padding: 8px 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.omaestro-video-toolbar.hidden {
    display: none !important;
}

.omaestro-video-toolbar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.omaestro-video-btn {
    border: 1px solid #3f3f46;
    background: #27272a;
    color: #e4e4e7;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.omaestro-video-btn:hover {
    background: #3f3f46;
}

.omaestro-video-model-label {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--omaestro-muted);
}

.omaestro-video-model-select {
    border: 1px solid #3f3f46;
    background: #18181b;
    color: #e4e4e7;
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 12px;
}

.omaestro-video-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.omaestro-video-tab {
    border: 1px solid #3f3f46;
    background: #18181b;
    color: #a1a1aa;
    border-radius: 8px;
    padding: 8px 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.omaestro-video-tab.is-active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
    color: #dbeafe;
}

.omaestro-video-chats-panel {
    border: 1px solid #3f3f46;
    border-radius: 10px;
    background: #111114;
    max-height: 180px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.omaestro-video-chats-panel.hidden {
    display: none !important;
}

.omaestro-video-chats-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid #27272a;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--omaestro-muted);
}

.omaestro-video-chats-close {
    border: none;
    background: transparent;
    color: #a1a1aa;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.omaestro-video-chats-list {
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.omaestro-video-chats-empty {
    color: var(--omaestro-muted);
    font-size: 12px;
    text-align: center;
    padding: 12px 8px;
}

.omaestro-video-chat-item {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 10px;
    text-align: left;
    background: transparent;
    color: #e4e4e7;
    cursor: pointer;
    font-size: 12px;
}

.omaestro-video-chat-item:hover {
    background: #27272a;
}

.omaestro-video-chat-item.is-active {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.1);
}
