.ai-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.tool-panel.ai-tools-only {
    position: relative;
}

label.drag-zone {
    display: block;
    width: 100%;
}

.ai-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 300;
}

.ai-toolbar select {
    min-width: 84px;
}

.ai-toolbar input[type="range"] {
    width: 130px;
    padding: 0;
}

.ai-toolbar input[type="number"] {
    width: 88px;
}

.ai-canvas-stage {
    width: min(100%, 1100px);
    aspect-ratio: 16 / 9;
    background: #050506;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.ai-canvas-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ai-image-stage {
    display: none;
    height: auto;
    min-height: 240px;
    max-height: 70vh;
    aspect-ratio: auto;
}

.ai-image-stage.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-image-stage canvas {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 70vh;
}

.ai-status {
    margin-top: 1rem;
}

.ai-media-preview {
    display: none;
    width: min(100%, 720px);
    margin-top: 1rem;
}

.ai-media-preview.visible {
    display: block;
}

.ai-video-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.ai-video-grid > div {
    min-width: 0;
}

.ai-video-grid span {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.ai-video-grid video,
.ai-video-grid canvas {
    display: block;
    width: 100%;
    min-height: 220px;
    max-height: 58vh;
    object-fit: contain;
    background: #050506;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.ai-yolo-upload-grid,
.ai-yolo-inspector {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
}

.ai-yolo-upload-grid {
    margin-bottom: 1rem;
}

.ai-yolo-upload-grid .drag-zone {
    height: 100%;
    min-height: 104px;
}

.ai-yolo-optional-drop {
    color: var(--text-muted);
    border-style: dashed;
}

.ai-yolo-inspector {
    margin: 1rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.ai-yolo-inspector section {
    min-width: 0;
}

.ai-yolo-inspector section + section {
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.ai-yolo-inspector h3 {
    margin: 0 0 0.75rem;
    color: var(--text-heading);
    font-size: 0.95rem;
    font-weight: 400;
}

.ai-yolo-kv {
    display: grid;
    grid-template-columns: minmax(74px, auto) minmax(0, 1fr);
    gap: 0.45rem 0.8rem;
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.6;
}

.ai-yolo-kv dt {
    color: var(--text-muted);
}

.ai-yolo-kv dd {
    min-width: 0;
    margin: 0;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.ai-yolo-note {
    margin: 0.35rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.6;
}

.ai-yolo-class-list {
    display: flex;
    max-height: 180px;
    gap: 0.4rem;
    flex-wrap: wrap;
    overflow: auto;
}

.ai-yolo-class-list span {
    padding: 0.3rem 0.45rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

.ai-yolo-preview {
    display: none;
}

.ai-yolo-preview.visible {
    display: grid;
}

.ai-yolo-detections {
    margin-top: 1rem;
    overflow: auto;
}

.ai-yolo-detection-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.ai-yolo-detection-table th,
.ai-yolo-detection-table td {
    padding: 0.5rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.78rem;
    font-weight: 300;
    white-space: nowrap;
}

.ai-yolo-detection-table th {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 300;
}

.ai-warning {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
}

.ai-warning[hidden] {
    display: none;
}

.ai-warning-dialog {
    width: min(100%, 560px);
    padding: 1.6rem;
    background: rgba(18, 18, 22, 0.98);
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
}

.ai-warning-dialog h2 {
    margin-bottom: 1rem;
    color: var(--text-heading);
    font-size: 1.3rem;
    font-weight: 400;
}

.ai-warning-dialog p {
    margin: 0.75rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.75;
}

.ai-warning-device {
    margin-top: 1rem;
    padding: 0.75rem;
    color: var(--warning);
    background: rgba(255, 204, 80, 0.07);
    border-left: 2px solid var(--warning);
    font-size: 0.82rem;
    line-height: 1.6;
}

.ai-warning-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.2rem;
}

@media (max-width: 768px) {
    .ai-tools-only,
    [id^="panel-ai-"],
    .ai-warning {
        display: none !important;
    }
}

@media (max-width: 980px) {
    .ai-video-grid,
    .ai-yolo-upload-grid,
    .ai-yolo-inspector {
        grid-template-columns: 1fr;
    }

    .ai-yolo-inspector section + section {
        padding-top: 1rem;
        padding-left: 0;
        border-top: 1px solid var(--border-color);
        border-left: 0;
    }
}
